DoubleWood 兄,干脆还是让你的 Delphi 帮我生成二进制代码吧:)
我根据 beta5 的算法写了个 OP 版的实现,麻烦 DoubleWood 兄再
帮忙测试一下:)
function HexToInt_beta6(const S: string): DWORD;
const
SmallTbl: array [0..255] of Byte = (
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 16, 16, 16, 16, 16, 16,
16, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16);
var
i, Len: Integer;
PResult: PChar;
begin
PResult := PChar(Integer(@Result) + 4);
Len := PInteger(Integer(S) - 4)^;
if Len <= 0 then
Exit;
if Odd(Len) then
begin
Dec(PResult);
PResult^ := Chr(SmallTbl[Ord(S[1])]);
if PResult^ >= Chr(16) then
begin
Result := 0;
Exit;
end;
end;
i := 1;
while i <= Len do
begin
Dec(PResult);
if (S <= 'f') and (S[i + 1] <= 'f') then
PResult^ := Chr(BetaTable5[PWord(@S)^])
else begin
Result := 0;
Exit;
end;
Inc(i);
Inc(i);
end;
end;
在我这里 beta6 和 beta5 速度几乎一样,要是在你那里速度相差很大,
就很说明问题了;而要是还是一样,我就真的无语言了。