Skip to content
Permalink
Browse files

refactoring of JSON/text/numbers/uri parsing

- using optimized lookup tables for branchless decoding
- FPC is not efficient when compiling P^ in [....] or case P^ of ....
  • Loading branch information
Arnaud Bouchez
Arnaud Bouchez committed Mar 26, 2020
1 parent 24919a7 commit 64a6a477a32c72dc89f8d4db5e2346eb6bf7d96c
Showing with 497 additions and 455 deletions.
  1. +5 −5 SQLite3/mORMot.pas
  2. +419 −416 SynCommons.pas
  3. +3 −3 SynDB.pas
  4. +1 −1 SynMongoDB.pas
  5. +54 −10 SynSelfTests.pas
  6. +14 −14 SynTable.pas
  7. +0 −5 Synopse.inc
  8. +1 −1 SynopseCommit.inc
begin
result := true;
B := F;
while ord(F^) in IsIdentifier do inc(F); // go to end of sub-field name
while tcIdentifier in TEXT_CHARS[F^] do inc(F); // go to end of sub-field name
if B=F then begin
result := false;
exit;
end;
begin
B := P;
while ord(P^) in IsIdentifier do inc(P); // go to end of field name
while tcIdentifier in TEXT_CHARS[P^] do inc(P); // go to end of field name
FastSetString(result,B,P-B);
if (result='') or IdemPropNameU(result,'AND') or IdemPropNameU(result,'OR') or
IdemPropNameU(result,'LIKE') or IdemPropNameU(result,'NOT') or
JBeg := pointer(aSQLJoin);
repeat
J := JBeg;
while not (ord(J^) in IsIdentifier) do begin
while not (tcIdentifier in TEXT_CHARS[J^]) do begin
case J^ of
'"': repeat inc(J) until J^ in [#0,'"'];
'''': repeat inc(J) until J^ in [#0,''''];
inc(i,6);
while SQL[i] in [#1..' '] do inc(i);
j := 0;
while ord(SQL[i+j]) in IsIdentifier do inc(j);
while tcIdentifier in TEXT_CHARS[SQL[i+j]] do inc(j);
if cardinal(j-1)<64 then begin
k := i+j;
while SQL[k] in [#1..' '] do inc(k);
repeat
while SQL[i] in [#1..' '] do inc(i);
j := 0;
while ord(SQL[i+j]) in IsIdentifier do inc(j);
while tcIdentifier in TEXT_CHARS[SQL[i+j]] do inc(j);
if cardinal(j-1)>64 then begin
result := nil;
exit; // seems too big

0 comments on commit 64a6a47

Please sign in to comment.
You can’t perform that action at this time.