From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Most efficient way to check for null string?
Date: 1997/06/20
Date: 1997-06-20T00:00:00+00:00 [thread overview]
Message-ID: <EC3A2y.970@world.std.com> (raw)
In-Reply-To: 5oe038$2d0$1@goanna.cs.rmit.edu.au
In article <5oe038$2d0$1@goanna.cs.rmit.edu.au>,
Dale Stanbrough <dale@goanna.cs.rmit.EDU.AU> wrote:
>I think the following are both equally readable, so which is likely
>to be more efficient?
>
> if Str = "" then
>
> if Str'Length = 0 then
I find the first slightly more readable. I suspect they're very close
to the same efficiency. I suspect that the second is at least as
efficient as the first (i.e. I would be surprised if a compiler did
worse on #2, but I would not be surprised if they were equal, or maybe
#2 slightly better).
The only sensible way to answer this question is to measure it.
It's quite easy to write a compiler where #1 is as efficient as #2. If
a given compiler doesn't do that, I take it as an indication that its
customers don't care about this sort of thing.
- Bob
next prev parent reply other threads:[~1997-06-20 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-06-20 0:00 Most efficient way to check for null string? Dale Stanbrough
1997-06-20 0:00 ` Tucker Taft
1997-06-21 0:00 ` Robert A Duff
1997-06-21 0:00 ` Robert Dewar
1997-06-23 0:00 ` Tucker Taft
1997-06-23 0:00 ` Richard Kenner
1997-06-20 0:00 ` Robert A Duff [this message]
1997-06-20 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox