Re: Fastcode CharPosRev B&V 0.6.0
- From: "Davy Landman" <davy.landman@xxxxxxxxx>
- Date: Mon, 27 Nov 2006 19:37:54 +0100
Hi John,
I made your version to an range checking safe one, but it's a little bit
slower because the P := part
on your program becomes:
lea edx,[edx+esi-$0c]
while mine solution:
mov eax,edi
xor edx,edx
push edx
push eax
mov eax,esi
sub eax,$0c
cdq
add eax,[esp]
adc edx,[esp+$04]
add esp,$08
so that's a bummer :(
anyone have an better idea?
this is the function by the way...
function CharPosRev_DLA_PAS_9_a(SearchChar: Char; const S: string): Integer;
var
P: PByteArray;
{ Made John's PAS_03 range checking save }
begin
Result := Length(S);
if Result > 0 then
begin
P := Pointer(Cardinal(S) + (Result - 12));
repeat
if P^[11] = Byte(SearchChar) then
Exit;
if P^[10] = Byte(SearchChar) then
begin
Dec(Result);
Break;
end;
if P^[9] = Byte(SearchChar) then
begin
Dec(Result, 2);
Break;
end;
if P^[8] = Byte(SearchChar) then
begin
Dec(Result, 3);
Break;
end;
Dec(Result, 4);
if Result <= 0 then
Break;
if P^[7] = Byte(SearchChar) then
Exit;
if P^[6] = Byte(SearchChar) then
begin
Dec(Result);
Break;
end;
if P[5] = Byte(SearchChar) then
begin
Dec(Result, 2);
Break;
end;
if P[4] = Byte(SearchChar) then
begin
Dec(Result, 3);
Break;
end;
Dec(Result, 4);
if Result <= 0 then
Break;
if P[3] = Byte(SearchChar) then
Exit;
if P[2] = Byte(SearchChar) then
begin
Dec(Result);
Break;
end;
if P[1] = Byte(SearchChar) then
begin
Dec(Result, 2);
Break;
end;
if P^[0] = Byte(SearchChar) then
begin
Dec(Result, 3);
Break;
end;
Dec(Result, 4);
if Result <= 0 then
Break;
P := Pointer(Cardinal(P) - 12);
until False;
if Result < 0 then {Match Found before First Char}
Result := 0;
end;
end;
Regards,
Davy
.
- Follow-Ups:
- Re: Fastcode CharPosRev B&V 0.6.0
- From: Davy Landman
- Re: Fastcode CharPosRev B&V 0.6.0
- From: Davy Landman
- Re: Fastcode CharPosRev B&V 0.6.0
- References:
- Fastcode CharPosRev B&V 0.6.0
- From: Dennis
- Re: Fastcode CharPosRev B&V 0.6.0
- From: Davy Landman
- Re: Fastcode CharPosRev B&V 0.6.0
- From: John O'Harrow
- Fastcode CharPosRev B&V 0.6.0
- Prev by Date: Re: Fastcode CharPosRev B&V 0.6.0
- Next by Date: Re: Fastcode CharPosRev B&V 0.6.0
- Previous by thread: Re: Fastcode CharPosRev B&V 0.6.0
- Next by thread: Re: Fastcode CharPosRev B&V 0.6.0
- Index(es):
Relevant Pages
|