codetools: TBaseKeyWordFunctionList: do not sort on add

git-svn-id: trunk@57149 -
This commit is contained in:
mattias 2018-01-26 09:42:38 +00:00
parent eb52382d06
commit e568cca991

View File

@ -87,7 +87,7 @@ type
function AllwaysFalse: boolean; function AllwaysFalse: boolean;
property Count: integer read FCount; property Count: integer read FCount;
function GetItem(Index: integer): TBaseKeyWordFunctionListItem; function GetItem(Index: integer): TBaseKeyWordFunctionListItem;
function IndexOf(const AKeyWord: shortstring): integer; function IndexOf(const AKeyWord: shortstring; UseSort: boolean): integer;
function CalcMemSize: PtrUInt; function CalcMemSize: PtrUInt;
property HasOnlyIdentifiers: boolean read FHasOnlyIdentifiers; property HasOnlyIdentifiers: boolean read FHasOnlyIdentifiers;
property Name: string read FName write FName; property Name: string read FName write FName;
@ -398,7 +398,7 @@ var
i: Integer; i: Integer;
begin begin
for i:=0 to List.FCount-1 do begin for i:=0 to List.FCount-1 do begin
if IndexOf(List.FItems[i].KeyWord)<0 then begin if IndexOf(List.FItems[i].KeyWord,false)<0 then begin
AddExtended(List.FItems[i].KeyWord,List.FItems[i].DoIt, AddExtended(List.FItems[i].KeyWord,List.FItems[i].DoIt,
List.FItems[i].DoDataFunction); List.FItems[i].DoDataFunction);
end; end;
@ -511,23 +511,29 @@ begin
Result:=FItems[Index]; Result:=FItems[Index];
end; end;
function TBaseKeyWordFunctionList.IndexOf(const AKeyWord: shortstring): integer; function TBaseKeyWordFunctionList.IndexOf(const AKeyWord: shortstring;
UseSort: boolean): integer;
var var
i: Integer; i: Integer;
begin begin
if not Sorted then Sort; if UseSort then begin
if not Sorted then Sort;
i:=KeyWordToHashIndex(AKeyWord); i:=KeyWordToHashIndex(AKeyWord);
if i>=0 then begin
i:=FBucketStart[i];
if i>=0 then begin if i>=0 then begin
repeat i:=FBucketStart[i];
if CompareText(FItems[i].KeyWord,AKeyWord)=0 then if i>=0 then begin
exit(i); repeat
if FItems[i].IsLast then break; if CompareText(FItems[i].KeyWord,AKeyWord)=0 then
inc(i); exit(i);
until false; if FItems[i].IsLast then break;
inc(i);
until false;
end;
end; end;
end else begin
for i:=0 to FCount-1 do
if CompareText(FItems[i].KeyWord,AKeyWord)=0 then exit(i);
end; end;
Result:=-1; Result:=-1;
end; end;