Re: Fastcode CompareStr B&V 1.1
- From: "Aleksandr Sharahov" <alsha-on-mail333.com>
- Date: Sun, 11 Sep 2005 12:24:06 +0400
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;
.
- Follow-Ups:
- Re: Fastcode CompareStr B&V 1.1
- From: Pierre le Riche
- Re: Fastcode CompareStr B&V 1.1
- From: Aleksandr Sharahov
- Re: Fastcode CompareStr B&V 1.1
- References:
- Fastcode CompareStr B&V 1.1
- From: Dennis
- Re: Fastcode CompareStr B&V 1.1
- From: Dennis
- Re: Fastcode CompareStr B&V 1.1
- From: Dennis
- Re: Fastcode CompareStr B&V 1.1
- From: Pierre le Riche
- Fastcode CompareStr B&V 1.1
- Prev by Date: Re: Alternative SZ IntToStrB&V v0.02
- Next by Date: Alternative SZ IntToStrB&V v0.04
- Previous by thread: Re: Fastcode CompareStr B&V 1.1
- Next by thread: Re: Fastcode CompareStr B&V 1.1
- Index(es):