我使用以下函数来交换(无)符号 64 位整数值:
function Swap64(I: Int64): Int64;
begin
Int64Rec(Result).Bytes[0] := Int64Rec(I).Bytes[7];
Int64Rec(Result).Bytes[1] := Int64Rec(I).Bytes[6];
Int64Rec(Result).Bytes[2] := Int64Rec(I).Bytes[5];
Int64Rec(Result).Bytes[3] := Int64Rec(I).Bytes[4];
Int64Rec(Result).Bytes[4] := Int64Rec(I).Bytes[3];
Int64Rec(Result).Bytes[5] := Int64Rec(I).Bytes[2];
Int64Rec(Result).Bytes[6] := Int64Rec(I).Bytes[1];
Int64Rec(Result).Bytes[7] := Int64Rec(I).Bytes[0];
end;
Run Code Online (Sandbox Code Playgroud)
我如何在 ASM 中做同样的事情以使其更快?
是否有任何Delphi实现的MurMurHash 3?我自己尝试实现它,但我的实现实际上比MurMurHash2慢.这是正常的吗?还有其他实施吗?
这是我的:
function MurMur3_32(const S: AnsiString; const Seed: LongWord=$9747b28c): LongWord;
const
c1 = $cc9e2d51;
c2 = $1b873593;
r1 = 15;
r2 = 13;
m = 5;
n = $e6546b64;
var
hash: LongWord;
len: LongWord;
k, k2: LongWord;
data: Integer;
begin
Hash := Seed;
len := Length(S);
//The default seed, $9747b28c, is from the original C library
// Initialize the hash to a 'random' value
hash := seed xor len;
// Mix 4 bytes at a time into …Run Code Online (Sandbox Code Playgroud)