Skip to content
Permalink
Browse files

rewrite some pointer arithmetic to enhance cross-compiler and cross-C…

…PU abilities
  • Loading branch information...
Arnaud Bouchez
Arnaud Bouchez committed Jul 24, 2019
1 parent 82b85d3 commit 4bd4bc713b3421451a035e67588ad9e8fb97e47d
Showing with 12 additions and 12 deletions.
  1. +4 −4 CrossPlatform/SynCrossPlatformSynLZ.pas
  2. +1 −1 PasZip.pas
  3. +5 −5 SynTable.pas
  4. +1 −1 SynZipFiles.pas
  5. +1 −1 SynopseCommit.inc
@@ -124,7 +124,7 @@ function SynLZcomp(src: pointer; size: cardinal; dst: pointer): cardinal;
CWbit := 1;
CWpoint := pointer(dst);
PCardinal(dst)^ := 0;
inc(PtrUInt(dst),sizeof(CWpoint^));
inc(PByte(dst),sizeof(CWpoint^));
fillchar(offset,sizeof(offset),0); // fast 16KB reset to 0
// 1. main loop to search using hash[]
if PtrUInt(src)<=src_endmatch then
@@ -145,7 +145,7 @@ function SynLZcomp(src: pointer; size: cardinal; dst: pointer): cardinal;
tmax := (255+16);
while (PBytes(o)[t]=PBytes(src)[t]) and (t<tmax) do
inc(t);
inc(PtrUInt(src),t);
inc(PByte(src),t);
h := h shl 4;
// here we have always t>0
if t<=15 then begin // mark 2 to 17 bytes -> size=1..15
@@ -155,7 +155,7 @@ function SynLZcomp(src: pointer; size: cardinal; dst: pointer): cardinal;
dec(t,16);
PWord(dst)^ := h; // size=0
PByte(PtrUInt(dst)+2)^ := t;
inc(PtrUInt(dst),3);
inc(PByte(dst),3);
end;
end else begin
PByte(dst)^ := PByte(src)^;
@@ -250,7 +250,7 @@ function SynLZdecomp(src: pointer; size: cardinal; dst: pointer): cardinal;
v := PCardinal(last_hashed)^;
offset[((v shr 12) xor v) and 4095] := last_hashed;
end;
inc(PtrUInt(dst),t);
inc(PByte(dst),t);
last_hashed := PtrUInt(dst)-1;
CWbit := CWbit shl 1;
if CWbit<>0 then
@@ -4233,7 +4233,7 @@ constructor TZipRead.Create(BufZip: pByteArray; Size: cardinal);
inc(p);
until j = L;
Name[j] := #0; // make ASCIIZ
inc(PtrUInt(H), sizeof(H^) + info^.NameLen + H^.fileInfo.extraLen + H^.commentLen);
inc(PByte(H), sizeof(H^) + info^.NameLen + H^.fileInfo.extraLen + H^.commentLen);
if (info^.zZipMethod in [0, 8]) and (Name[j - 1] <> '\') then
inc(Count); // known methods: stored + deflate
end;
@@ -4570,15 +4570,15 @@ function TSynTable.GetData(RecordBuffer: PUTF8Char; Field: TSynTableFieldPropert
if i in fFieldIsVarString then begin
// inlined result := GotoNextVarString(result);
if PByte(result)^<=$7f then
inc(PtrUInt(result),PByte(result)^+1) else begin
inc(PByte(result),PByte(result)^+1) else begin
PB := result;
inc(PtrUInt(result),FromVarUInt32High(PB)+PtrUInt(PB)-PtrUInt(result));
inc(PByte(result),FromVarUInt32High(PB)+PtrUInt(PB)-PtrUInt(result));
end;
end else
if not (i in fFieldIsExternal) then begin
// inlined result := GotoNextVarInt(result)
while PByte(result)^>$7f do inc(PtrUInt(result));
inc(PtrUInt(result));
while PByte(result)^>$7f do inc(PByte(result));
inc(PByte(result));
end;
end;
end;
@@ -4724,7 +4724,7 @@ function TSynTable.UpdateFieldEvent(Sender: TObject; Opaque: pointer;
// add previous field content: will handle any field offset change in record
aSize := Getlength(Data);
WR.Write(Data,aSize);
inc(PtrUInt(Data),aSize);
inc(PByte(Data),aSize);
end else
// add default field content for a newly added field
WR.Write(Pointer(fDefaultFieldData),fDefaultFieldLength);
@@ -490,7 +490,7 @@ procedure Error(const msg: string);
ZipName := StringReplaceChars(ZipName,'/','\');
Header := H^;
end; // next entry is after the ZipNname and some extra/comment
inc(PtrUInt(H),sizeof(H^)+fileInfo.nameLen+fileInfo.extraLen+commentLen);
inc(PByte(H),sizeof(H^)+fileInfo.nameLen+fileInfo.extraLen+commentLen);
end;
end;

@@ -1 +1 @@
'1.18.5283'
'1.18.5284'

0 comments on commit 4bd4bc7

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