Ver código fonte

StringParse - without unnecessary conversions, speedup~12%

Alligator-1 4 semanas atrás
pai
commit
00c6fbe8ba

+ 1 - 1
packages/fcl-json/src/jsonreader.pp

@@ -246,7 +246,7 @@ begin
     tkNull  : NullValue;
     tkTrue,
     tkFalse : BooleanValue(t=tkTrue);
-    tkString : if (joUTF8 in Options) and (DefaultSystemCodePage<>CP_UTF8) then
+    tkString : if ((joUTF8 in Options) or (DefaultSystemCodePage<>CP_UTF8)) and (TypeInfo(TJSONStringType) <> TypeInfo(UTF8String)) then
                  StringValue(TJSONStringType(UTF8Decode(CurrentTokenString)))
                else
                  StringValue(CurrentTokenString);

+ 2 - 2
packages/fcl-json/src/jsonscanner.pp

@@ -525,8 +525,8 @@ begin
           Inc(Rp, CodepointToASCII(cp, Rp));
     end;
   end;
-  if not utf8 then
-    SetLength(FCurTokenString, Rp - PAnsiChar(Pointer(FCurTokenString)));
+  if utf8 then
+    SetCodePage(RawByteString(FCurTokenString), CP_UTF8, FALSE);
   FPartsBytes := -1;
 end;