IdeIntf: Reduce calls to UpperCase() and LowerCase().

git-svn-id: trunk@64548 -
This commit is contained in:
juha 2021-02-12 10:26:41 +00:00
parent 7e625598d0
commit d608622e30
3 changed files with 30 additions and 42 deletions

View File

@ -510,8 +510,7 @@ type
write FDefaultItemHeight default 0;
property DrawHorzGridLines: Boolean read FDrawHorzGridLines write
SetDrawHorzGridLines default True;
property ExpandedProperties: TStringList read FExpandedProperties
write FExpandedProperties;
property ExpandedProperties: TStringList read FExpandedProperties;
property Indent: integer read FIndent write FIndent;
property ItemIndex: integer read FItemIndex write SetItemIndex;
property Layout: TOILayout read FLayout write FLayout default oilHorizontal;
@ -907,8 +906,8 @@ implementation
function SortGridRows(Item1, Item2 : pointer) : integer;
begin
Result:=SysUtils.CompareText(TOIPropertyGridRow(Item1).Name,
TOIPropertyGridRow(Item2).Name);
Result:=CompareText(TOIPropertyGridRow(Item1).Name,
TOIPropertyGridRow(Item2).Name);
end;
function dbgs(s: TOIPropertyGridState): string;
@ -1446,7 +1445,8 @@ end;
function TOICustomPropertyGrid.GetRowByPath(const PropPath: string): TOIPropertyGridRow;
// searches PropPath. Expands automatically parent rows
var CurName:string;
var
CurName:string;
s,e:integer;
CurParentRow:TOIPropertyGridRow;
begin
@ -1457,14 +1457,14 @@ begin
while (s<=length(PropPath)) do begin
e:=s;
while (e<=length(PropPath)) and (PropPath[e]<>'.') do inc(e);
CurName:=uppercase(copy(PropPath,s,e-s));
CurName:=copy(PropPath,s,e-s);
s:=e+1;
// search name in children
if CurParentRow=nil then
Result:=Rows[0]
else
Result:=CurParentRow.FirstChild;
while (Result<>nil) and (uppercase(Result.Name)<>CurName) do
while (Result<>nil) and (CompareText(Result.Name, CurName)<>0) do
Result:=Result.NextBrother;
if Result=nil then begin
exit;
@ -2058,11 +2058,11 @@ begin
SetItemsTops;
FExpandingRow.FExpanded := True;
a := 0;
CurPath:=uppercase(PropertyPath(FExpandingRow.Index));
CurPath:=PropertyPath(FExpandingRow.Index);
AlreadyInExpandList:=false;
while a < FExpandedProperties.Count do
begin
if FExpandedProperties[a]=copy(CurPath,1,length(FExpandedProperties[a])) then
if LazStartsText(FExpandedProperties[a], CurPath) then
begin
if Length(FExpandedProperties[a]) = Length(CurPath) then
begin
@ -2123,17 +2123,17 @@ begin
end;
SetItemsTops;
CurRow.FExpanded := False;
CurPath := UpperCase(PropertyPath(CurRow.Index));
CurPath := PropertyPath(CurRow.Index);
a := 0;
while a < FExpandedProperties.Count do
begin
if StartsStr(CurPath, FExpandedProperties[a]) then
if LazStartsText(CurPath, FExpandedProperties[a]) then
FExpandedProperties.Delete(a)
else
inc(a);
end;
if CurRow.Parent <> nil then
FExpandedProperties.Add(UpperCase(PropertyPath(CurRow.Parent.Index)));
FExpandedProperties.Add(PropertyPath(CurRow.Parent.Index));
UpdateScrollBar;
Invalidate;
end;
@ -2527,8 +2527,8 @@ var
else
IIndex := ItemIndex;
for i := 0 to RowCount - 1 do
if (Rows[i].Lvl = Rows[IIndex].Lvl) and
(UpperCase(LeftStr(Rows[i].Name, Length(FKeySearchText))) = FKeySearchText) then
if (Rows[i].Lvl = Rows[IIndex].Lvl)
and LazStartsText(FKeySearchText, Rows[i].Name) then
begin
// Set item index. To go to Value user must hit either Tab or Enter.
SetItemIndex(i);

View File

@ -7680,11 +7680,6 @@ begin
Result := PTypeInfo(Value.ClassInfo);
end;
function ContainsTextUpper(const AText, AUpperSubText: string): Boolean;
begin
Result := Pos(AUpperSubText, UpperCase(AText)) > 0;
end;
procedure EditCollection(AComponent: TComponent; ACollection: TCollection; APropName: String);
begin
TCollectionPropertyEditor.ShowCollectionEditor(ACollection, AComponent, APropName);
@ -7700,7 +7695,6 @@ function IsInteresting(AEditor: TPropertyEditor; const AFilter: TTypeKinds;
var
visited: TFPList;
UpperPropName: String;
// check set element names against AFilter
function IsPropInSet( const ATypeInfo: PTypeInfo ) : Boolean;
@ -7721,7 +7715,7 @@ var
for i:= TypeData^.MinValue to TypeData^.MaxValue do
begin
Result := ContainsTextUpper( GetEnumName(TypeInfo, i), UpperPropName );
Result := PosI(APropNameFilter, GetEnumName(TypeInfo,i)) > 0;
if Result then
Break;
end;
@ -7748,7 +7742,7 @@ var
begin
propInfo := propList^[i];
Result := ContainsTextUpper(propInfo^.Name, UpperPropName);
Result := PosI(APropNameFilter, propInfo^.Name) > 0;
if Result then break;
//if encounter a Set check its elements name.
if (propInfo^.PropType^.Kind = tkSet) then
@ -7786,17 +7780,13 @@ var
Result := ti^.Kind <> tkClass;
if Result then
begin
if (UpperPropName = '') or AForceShow then
if (APropNameFilter = '') or AForceShow then
exit;
Result := PosI(APropNameFilter, A.GetName) > 0; // Check single Props
// Check if check Set has element.
if (ti^.Kind = tkSet) and (A.ClassType <> TSetElementPropertyEditor) then
begin
Result := ContainsTextUpper(A.GetName, UpperPropName)
or IsPropInSet(A.GetPropType);
exit;
end;
// Check single Props
Result := ContainsTextUpper(A.GetName, UpperPropName);
Result := Result or IsPropInSet(A.GetPropType);
exit;
end;
@ -7812,12 +7802,11 @@ var
if Result then
begin
// if no SubProperties check against filter name
if (UpperPropName <> '') then
if (paSubProperties in A.GetAttributes) then
Result := ContainsTextUpper(A.GetName, UpperPropName)
or IsPropInClass(A.GetPropType)
else
Result := ContainsTextUpper(A.GetName, UpperPropName);
if (APropNameFilter = '') then
exit;
Result := PosI(APropNameFilter, A.GetName) > 0;
if (paSubProperties in A.GetAttributes) then
Result := Result or IsPropInClass(A.GetPropType);
exit;
end;
@ -7847,7 +7836,7 @@ var
ed.SetPropEntry(0, obj, propList^[i]);
ed.Initialize;
// filter TClassPropertyEditor name recursively
Rec(ed, ContainsTextUpper(A.GetName, UpperPropName) );
Rec(ed, PosI(APropNameFilter, A.GetName) > 0 );
finally
ed.Free;
end;
@ -7862,7 +7851,6 @@ var
begin
visited := TFPList.Create;
try
UpperPropName := Uppercase(APropNameFilter);
//DebugLn('IsInteresting -> ', AEditor.GetPropInfo^.Name, ': ', AEditor.GetPropInfo^.PropType^.Name);
Rec(AEditor);
//DebugLn('IsInteresting <- ', BoolToStr(Result, true));

View File

@ -114,12 +114,12 @@ begin
for i := 0 to AProperties.Count - 1 do begin
if AProperties[i] is TFlowPanelControlIndexProperty then
Exit;
propname := UpperCase(AProperties[i].GetName);
if propname = 'CONTROLINDEX' then
propname := AProperties[i].GetName;
if CompareText(propname, 'CONTROLINDEX') = 0 then
Exit
else if propname = 'LEFT' then
else if CompareText(propname, 'LEFT') = 0 then
todelete[0] := i
else if propname = 'TOP' then
else if CompareText(propname, 'TOP') = 0 then
todelete[1] := i;
end;