2828
2929interface
3030
31+ { $O+,W-,Q-,R-}
32+
3133function MurmurHash3 (const key; len: Cardinal; seed: Integer = 0 ): Integer;
3234
3335function MurmurHash3_Int32 (const key: Integer): Integer; // inline;
@@ -60,10 +62,10 @@ function xxHash32(const key; len: Cardinal; seed: Integer = 0): Integer;
6062 if len >= 16 then
6163 begin
6264 limit := pEnd - 16 ;
63- v1 := Seed + Prime1 + Prime2;
64- v2 := Seed + Prime2;
65- v3 := Seed ;
66- v4 := Seed - Prime1;
65+ v1 := Cardinal(seed) + Prime1 + Prime2;
66+ v2 := Cardinal(seed) + Prime2;
67+ v3 := Cardinal(seed) ;
68+ v4 := Cardinal(seed) - Prime1;
6769
6870 repeat
6971 v1 := Prime1 * RotateLeft(v1 + Prime2 * PCardinal(data)[0 ], 13 );
@@ -79,13 +81,13 @@ function xxHash32(const key; len: Cardinal; seed: Integer = 0): Integer;
7981 RotateLeft(v4, 18 );
8082 end
8183 else
82- Result := Seed + Prime5;
84+ Result := Cardinal(seed) + Prime5;
8385
8486 Inc(Result, len);
8587
8688 while data <= pEnd - 4 do
8789 begin
88- Result := Result + PCardinal(data)^ * Prime3;
90+ Result := Cardinal( Result) + PCardinal(data)^ * Prime3;
8991 Result := RotateLeft(Result, 17 ) * Prime4;
9092 Inc(data, 4 );
9193 end ;
@@ -98,9 +100,9 @@ function xxHash32(const key; len: Cardinal; seed: Integer = 0): Integer;
98100 end ;
99101
100102 Result := Result xor (Result shr 15 );
101- Result := Result * Prime2;
103+ Result := Cardinal( Result) * Prime2;
102104 Result := Result xor (Result shr 13 );
103- Result := Result * Prime3;
105+ Result := Cardinal( Result) * Prime3;
104106 Result := Result xor (Result shr 16 );
105107end ;
106108{ $ELSEIF defined(CPUX86)}
@@ -339,15 +341,19 @@ function MurmurHash3_Int32(const key: Integer): Integer;
339341 f1 = $85EBCA6B;
340342 f2 = $C2B2AE35;
341343{ $IF not defined(ASSEMBLER)}
344+ var
345+ res: Cardinal;
342346begin
343- Result := RotateLeft(key * c1, r1);
344- Result := RotateLeft(Result * c2, r2);
347+ res := Cardinal(key);
348+ res := RotateLeft(res * c1, r1);
349+ res := RotateLeft(res * c2, r2);
345350
346- Result := (Result * m + n) xor 4 ;
351+ res := (res * m + n) xor 4 ;
347352
348- Result := (Result xor (Result shr 16 )) * f1;
349- Result := (Result xor (Result shr 13 )) * f2;
350- Result := Result xor (Result shr 16 );
353+ res := (res xor (res shr 16 )) * f1;
354+ res := (res xor (res shr 13 )) * f2;
355+ res := res xor (res shr 16 );
356+ Result := res;
351357end ;
352358{ $ELSEIF defined(CPUX86)}
353359asm
@@ -420,9 +426,9 @@ function MurmurHash3(const key; len: Cardinal; seed: Integer = 0): Integer;
420426 k := RotateLeft(k, r1);
421427 k := k * c2;
422428
423- Result := Result xor k;
429+ Result := Cardinal( Result) xor k;
424430 Result := RotateLeft(Result, r2);
425- Result := Result * m + n;
431+ Result := Cardinal( Result) * m + n;
426432
427433 Inc(data);
428434 end ;
@@ -447,16 +453,16 @@ function MurmurHash3(const key; len: Cardinal; seed: Integer = 0): Integer;
447453 k := k * c1;
448454 k := RotateLeft(k, r1);
449455 k := k * c2;
450- Result := Result xor k;
456+ Result := Cardinal( Result) xor k;
451457 end ;
452458 end ;
453459
454- Result := Result xor len;
460+ Result := Cardinal( Result) xor len;
455461
456462 Result := Result xor (Result shr 16 );
457- Result := Result * f1;
463+ Result := Cardinal( Result) * f1;
458464 Result := Result xor (Result shr 13 );
459- Result := Result * f2;
465+ Result := Cardinal( Result) * f2;
460466 Result := Result xor (Result shr 16 );
461467end ;
462468{ $ELSEIF defined(CPUX86)}
0 commit comments