summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3289c5d)
raw | patch | inline | side by side (parent: 3289c5d)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 12 Oct 2019 21:51:21 +0000 (00:51 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 12 Oct 2019 22:15:53 +0000 (01:15 +0300) |
src/shared/hashtable.pas | patch | blob | history |
index 997a1dde3366dc8b2c7e18185ae093b23f52f4e4..ec7f54ba85a1b6d86ff9be43b1c63e842fcb7e99 100644 (file)
--- a/src/shared/hashtable.pas
+++ b/src/shared/hashtable.pas
function u32Hash (a: LongWord): LongWord; inline;
function fnvHash (constref buf; len: LongWord): LongWord;
function joaatHash (constref buf; len: LongWord; seed: LongWord=0): LongWord;
+function joaatHashPtr (buf: Pointer; len: LongWord; seed: LongWord=0): LongWord;
// has to be public due to FPC generics limitation
function nextPOTU32 (x: LongWord): LongWord; inline;
result := result xor (result shr 11);
result += (result shl 15);
end;
+
+function joaatHashPtr (buf: Pointer; len: LongWord; seed: LongWord=0): LongWord;
+var
+ b: PByte;
+ f: LongWord;
+begin
+ result := seed;
+ b := PByte(buf);
+ for f := 1 to len do
+ begin
+ result += b^;
+ result += (result shl 10);
+ result := result xor (result shr 6);
+ Inc(b);
+ end;
+ // finalize
+ result += (result shl 3);
+ result := result xor (result shr 11);
+ result += (result shl 15);
+end;
{$POP}
{$PUSH}
end;
{$POP}
-class function THashKeyStrAnsiCI.hash (const k: AnsiString): LongWord; inline; begin if (Length(k) > 0) then result := fnvHash((@k[1])^, Length(k)) else result := 0; end;
+class function THashKeyStrAnsiCI.hash (const k: AnsiString): LongWord; inline; begin if (Length(k) > 0) then result := fnvHashLo((@k[1])^, Length(k)) else result := 0; end;
class function THashKeyStrAnsiCI.equ (const a, b: AnsiString): Boolean; inline;
var
f: Integer;