From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,874f90f0816ffe3b X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Most efficient way to check for null string? Date: 1997/06/20 Message-ID: #1/1 X-Deja-AN: 251402771 References: <5oe038$2d0$1@goanna.cs.rmit.edu.au> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-06-20T00:00:00+00:00 List-Id: In article <5oe038$2d0$1@goanna.cs.rmit.edu.au>, Dale Stanbrough 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