Re: nulls



Gordon Cowie wrote:
this approach seems fastest so far..
its hard coded to search for just W,X,Y,Z

If you are really checking for WXYZ, try this code:

function IndexOfAny1(Source: Pointer; Length: Integer): Integer;
asm
push ebx
push esi
push edi
push ebp

mov ebp,eax
mov esi,eax
mov edi,edx //length

shr edi,2

@dwords:

mov al, [esi]
sub al, 'W'
cmp al, 'Z'-'W'
jbe @found1

mov bl, [esi+1]
sub bl, 'W'
cmp bl, 'Z'-'W'
jbe @found2

mov cl, [esi+2]
sub cl, 'W'
cmp cl, 'Z'-'W'
jbe @found3

mov dl, [esi+3]
sub dl, 'W'
cmp dl, 'Z'-'W'
jbe @found4

add esi,4
dec edi

jnz @dwords

mov eax,-1
pop ebp
pop edi
pop esi
pop ebx
ret

@found4:
inc esi
@found3:
inc esi
@found2:
inc esi
@found1:
inc esi

mov eax,esi
sub eax,ebp
dec eax

pop ebp
pop edi
pop esi
pop ebx
end;

Cheers,
Nicholas Sherlock

--
http://www.sherlocksoftware.org
.



Relevant Pages