Re: Fastcode CharPosRev B&V 0.6.0



Hi Dennis,

I created one new Pascal function...

On my Northwood it's slower.. but maybe on the other processors not?

I tried to get away the -1, -2, -3 .. Maybe it will be faster..
allthough it results in an extra dec eax instead of doing [edx-esi-$02] so..
who knows?

function CharPosRev_DLA_PAS_8(SearchChar: Char; const S: string): Integer;
var
p: PByteArray;
begin
Result := Length(S);
if Result <= 4 then
begin
p := Pointer(S);
for Result := Result downto 1 do
if p^[Result - 1] = Byte(SearchChar) then
begin
Exit;
end;
Result := 0;
Exit;
end;
Inc(Result, 3);
p := Pointer(Cardinal(S) - 4);
while Result >= 3 do
begin
if p^[Result] = Byte(SearchChar) then
begin
Dec(Result, 3);
Exit;
end;
Dec(Result);
if p^[Result] = Byte(SearchChar) then
begin
Dec(Result, 3);
Break;
end;
Dec(Result);
if p^[Result] = Byte(SearchChar) then
begin
Dec(Result, 3);
Break;
end;
Dec(Result);
if p^[Result] = Byte(SearchChar) then
begin
Dec(Result, 3);
Break;
end;
Dec(Result);
end;
if Result < 0 then {Match Found before First Char}
Result := 0;
end;

Regards,
Davy


.



Relevant Pages