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=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,25aa3c7e1b59f7b5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-07 08:29:31 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!in.nntp.be!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: Subject: Re: A case where Ada defaults to unsafe? Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Mon, 07 Jan 2002 11:24:15 EST Organization: http://www.newsranger.com Date: Mon, 07 Jan 2002 16:24:15 GMT Xref: archiver1.google.com comp.lang.ada:18605 Date: 2002-01-07T16:24:15+00:00 List-Id: In article , Gautier Write-only-address says... > >>If I use "and" and I'm wrong in assuming that the order doesn't matter, >>then I have introduced a subtle bug. If I'm right, then I haven't gained >>anything. So why not always use "and then"? > >The short circuit is not always the faster. A good compiler >can much more aggressively optimize an "x>=0 and x<=xmax" than >"x>=0 and then x<=xmax"; in addition "and then" introduces >branch(es) in the machine code, this is a performance >penalty on processors like the Pentiums. Except that processors like the Pentiums also have branch prediction and speculative execution. So it might not matter much after all. :-) It gets really hairy doesn't it? That's why the best decision is to usually let the compiler (and thus the CPU optimization experts) deal with it, rather than trying to use the more restrictive option to hand-optimize the sources yourself. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.