Procházet zdrojové kódy

ParseString string finalization ~0.5–1%

Alligator-1 před 3 týdny
rodič
revize
3b7f402136
1 změnil soubory, kde provedl 8 přidání a 6 odebrání
  1. 8 6
      packages/fcl-json/src/jsonreader.pp

+ 8 - 6
packages/fcl-json/src/jsonreader.pp

@@ -231,10 +231,15 @@ begin
 end;
 
 procedure TBaseJSONReader.DoParse(AtCurrent, AllowEOF: Boolean);
-
+  procedure ParseString;
+  begin
+    if ((joUTF8 in Options) or (DefaultSystemCodePage<>CP_UTF8)) and (TypeInfo(TJSONStringType) <> TypeInfo(UTF8String)) then
+      StringValue(TJSONStringType(UTF8Decode(CurrentTokenString)))
+    else
+      StringValue(CurrentTokenString);
+  end;
 var
   T : TJSONToken;
-  
 begin
   If not AtCurrent then
     T:=GetNextToken
@@ -246,10 +251,7 @@ begin
     tkNull  : NullValue;
     tkTrue,
     tkFalse : BooleanValue(t=tkTrue);
-    tkString : if ((joUTF8 in Options) or (DefaultSystemCodePage<>CP_UTF8)) and (TypeInfo(TJSONStringType) <> TypeInfo(UTF8String)) then
-                 StringValue(TJSONStringType(UTF8Decode(CurrentTokenString)))
-               else
-                 StringValue(CurrentTokenString);
+    tkString : ParseString;
     tkCurlyBraceOpen :
         ParseObject;
     tkCurlyBraceClose :