Re: Fastcode CompareStr B&V 1.1



Hi Pierre,

> 2) I have a neat way to avoid unnecessary nil string checks - I "and" the
> two pointers together and check whether the result is 0 instead of checking
> both individually.

It's wrong! Take look at the example below.

--
regards
Aleksandr


procedure TForm1.Button3Click(Sender: TObject);
var
s1, s2: string;
len, addr: integer;
begin
len:=MaxInt div 256;
repeat
len:=len+len;
SetLength(s1,len-12);
addr:=integer(s1);
until (len<0) or (addr<len);

if addr<len then begin
dec(len,addr);
SetLength(s1,len-12);
SetLength(s2,1);
ShowMessage(Format('%p'#13#10'%p'#13#10'%.8x',
[pointer(s1),pointer(s2),integer(s1) and integer(s2)]));
{
You will see (under d6/w98):
00CE000C
01000000
00000000
}
end;
end;



.