Small optimization for fpjson
Original Reporter info from Mantis: Alextp
-
Reporter name: CudaText man
Original Reporter info from Mantis: Alextp
- Reporter name: CudaText man
Description:
https://github.com/graemeg/freepascal/blob/master/packages/fcl-json/src/fpjson.pp
'u' : begin W:=Copy(S,I+1,4); Inc(I,4); u2:=StrToInt('$'+W);
I suggest to avoid str alloc here via this function from me
function BufferHexToInt(p: PWideChar; Len: integer): integer; //Alexey var N, i: integer; ch: WideChar; begin Result:= 0; for i:= 1 to Len do begin ch:= p^; case ch of '0'..'9': N:= Ord(ch)-Ord('0'); 'a'..'f': N:= Ord(ch)-(Ord('a')-10); 'A'..'F': N:= Ord(ch)-(Ord('A')-10); else exit(-1); end; Inc(p); Result:= Result*16+N; end; end;