Browse Source

IndexOfName (string finalization) another speedup ~1%

Alligator-1 3 weeks ago
parent
commit
52130578c4
1 changed files with 7 additions and 5 deletions
  1. 7 5
      packages/fcl-json/src/fpjson.pp

+ 7 - 5
packages/fcl-json/src/fpjson.pp

@@ -3900,6 +3900,12 @@ begin
 end;
 
 function TJSONObject.IndexOfName(const AName: TJSONStringType; CaseInsensitive : Boolean = False): Integer;
+  function IndexOfNameCaseInsensetive: Integer;
+  begin
+    Result:=Count-1;
+    while (Result>=0) and (CompareText(Names[Result],AName)<>0) do
+      Dec(Result);
+  end;
 begin
   {$IFDEF PAS2JS}
   if FNames=nil then
@@ -3909,11 +3915,7 @@ begin
   Result:=FHash.FindIndexOf(AName);
   {$ENDIF}
   if (Result<0) and CaseInsensitive then
-    begin
-    Result:=Count-1;
-    While (Result>=0) and (CompareText(Names[Result],AName)<>0) do
-      Dec(Result);
-    end;
+    Result:=IndexOfNameCaseInsensetive;
 end;
 
 procedure TJSONObject.Clear;