jsbattig / tries

Trie base class and derived classes (TStringHashTrie, TIntegerHashTrie). A high performance and low memory footprint Dictionary set of classes
MIT License
9 stars 2 forks source link

xxHash.pas xxHash64Calc get different result #13

Closed starteryao closed 6 years ago

starteryao commented 6 years ago

xxHash.pas

I test with Delphi10. xxHash32Calc('aa') or xxHash64Calc('aa') compared to a javascript lib, will get different result.
the following modification will get same result.

{$IFNDEF FPC} uses System.SysUtils; {$ENDIF}

function xxHash32Calc(const AString: string; ASeed: LongWord): LongWord; begin Result := xxHash32Calc({$IFNDEF FPC}TEncoding.UTF8.GetBytes{$ELSE} PChar {$ENDIF}(AString), length(AString), ASeed); end;

function xxHash64Calc(const AString: string; ASeed: QWord): QWord; begin Result := xxHash64Calc({$IFNDEF FPC}TEncoding.UTF8.GetBytes{$ELSE} PChar {$ENDIF} (AString), length(AString), ASeed); end;

jsbattig commented 6 years ago

@starteryao , please check my latest commit. should fix the problem