On 07 Mar 2008, at 15:09, Damien Gerard wrote:

Le Mar 7, 2008 à 2:54 PM, Jonas Maebe a écrit :


On 03 Mar 2008, at 17:16, Damien Gerard wrote:

In any programs, a lot of tests on empty strings are made.
The following made the work :
if Length(s) <> 0 then ...
or
if s <> '' then ...

In a lot of cases, the real length is no needed, just to know if the string is empty or not.

That is what "if s <> '' then" checks for. This is already generated as optimally as possible.

In a previous thread, I have ask the difference between (Length(s) = 0) and (s = '')

Copy paste a answer :


if s = '' then ...
of this one
if Length(s) <> 0 then ...

Both generate the same code.

Consequently, it can not be the same code. Otherwise I understood nothing :)

I don't understand your question. Above, you say that these statements work:

if Length(s) <> 0 then ...
or
if s <> '' then ...

(or does "made the work" mean something else?). If that indeed works, then everything is fine, because
a) both indeed generate the same code
b) both check whether the string is empty or not (without actually looking at the length)


Jonas_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to