Wow, thats pretty yuck, you would think on the face of it that it would be
quicker.  But oh well.  Back to using A = ''; which I had thought would have
been slowest.

An interesting thing to have learnt for the week.


Nahum.

> [EMAIL PROTECTED] <mailto:owner-delphi@;delphi.org.nz>
> wrote on
>
> That will be about 3 times or more slower than length(a) - given that
> A is a string.
>
> Delphi's handling of single characters in a string is rather
> horrible. It generally creates a temporary long string of 1 character
> copies from the original string and then does the compare - Yuck!!
> Plus of course you have just added a compiler generated try - finally
> around you block of code.
>
> Myles.
>
>
> -----Original Message-----
> From: Nahum Wild [mailto:Nahum.wild@;payglobal.com]
> Sent: Thursday, 31 October 2002 4:36 p.m.
> To: Multiple recipients of list delphi
> Subject: RE: [DUG]: Empty string test
>
>
> How about A[0] = 0; ?
>
>> [EMAIL PROTECTED] <mailto:owner-delphi@;delphi.org.nz> wrote
>> on
>>
>> Nope, That is the most efficient form ie (A = ''). The compiler does
>> a nice job of optimising it - basically a single instruction -
>> ignoring the jmp
>>
>> eg
>> cmp dword ptr [es],$00
>> jnz ...
>>
>> Compare this to Length(A)
>>
>> Move eax, ecx
>> Call @LStrLen
>> test eax,eax
>> jnz ...
>>
>> And LStrLen is
>> tst eax,eax
>> jz $03
>> mov eax,[eax-4]
>> ret
>>
>> Myles.
>>
>>
>>
>>
>>
>> -----Original Message-----
>> From: vss [mailto:vss@;vss.co.nz]
>> Sent: Thursday, 31 October 2002 4:04 p.m.
>> To: Multiple recipients of list delphi
>> Subject: Re: [DUG]: Empty string test
>>
>>
>> I second that. if legnth(mystring)=0 then showmessage('its empty')
>>
>> Jeremy
>>
>> -----Original Message-----
>> From: "Jeremy North" <[EMAIL PROTECTED]>
>> To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
>> Date: Thu, 31 Oct 2002 14:00:41 +1100
>> Subject: Re: [DUG]:  Empty string test
>>
>>>
>>> I was once told that checking the length was.
>>> The person that told me said that it was recommend by boundschecker
>>> application. JED
>>>
>>>> Whats the fastest way to test for an empty string
>>>> I just get the feeling that String = '' is not good practice
>>>
>>>
>>>
>>> This email and any files transmitted with it are confidential and
>>> intended solely for the use of the individual or entity to whom they
>>> are addressed. If you have received this email in error please
>>> notify the [EMAIL PROTECTED]
>>>
>>>
>> --------------------------------------------------------------
>> ---------
>>> ----
>>>     New Zealand Delphi Users group - Delphi List -
>>>                   [EMAIL PROTECTED] Website:
>>> http://www.delphi.org.nz To UnSub, send email to:
>>> [EMAIL PROTECTED] with body of "unsubscribe delphi"
>>> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
>>
>> --------------------------------------------------------------
>> -------------
>>     New Zealand Delphi Users group - Delphi List -
>> [EMAIL PROTECTED]
>>                   Website: http://www.delphi.org.nz
>> To UnSub, send email to: [EMAIL PROTECTED]
>> with body of "unsubscribe delphi"
>> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
>> --------------------------------------------------------------
>> -------------
>>     New Zealand Delphi Users group - Delphi List -
>> [EMAIL PROTECTED]
>>                   Website: http://www.delphi.org.nz
>> To UnSub, send email to: [EMAIL PROTECTED]
>> with body of "unsubscribe delphi"
>> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
>
>
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to