comp.lang.ada
 help / color / mirror / Atom feed
From: Martin <martin.dowie@btopenworld.com>
Subject: Re: Interesting performance quirk.
Date: Wed, 29 Oct 2008 03:19:53 -0700 (PDT)
Date: 2008-10-29T03:19:53-07:00	[thread overview]
Message-ID: <eb9af7dc-1c5e-45de-ab41-8a386fbe1385@u28g2000hsc.googlegroups.com> (raw)
In-Reply-To: 490833fc$0$5742$4d3efbfe@news.sover.net

On Oct 29, 9:59 am, "Peter C. Chapin" <pcc482...@gmail.com> wrote:
> In any event I don't want to "resort" to assembly language or to
> removing the Ada mandated checks (at least not in the final version).

With a bit of care a lot of checks can be avoided or removed by the
compiler. A fairly common example of this wrt loops is:

   type Array_Index_Type is range ...;
   type Array_Type is array (Array_Index_Type) of ...;

   procedure Example (A : Array_Type) is
   begin
      for I in Array_Index_Type loop
         -- Do something with array I - a check is often included
      end loop;
   end Example;

is better written as:

   procedure Example (A : Array_Type) is
   begin
      for I in A'Range loop
         -- Do something with array I - no need for a check
      end loop;
   end Example;

I'm not a language lawyer, so I can't tell if that's compiler
inefficiencies or what the language requires but this was certainly
the behaviour of several compilers I've used***.

Cheers
-- Martin

*** I haven't checked this recently!!! :-)



  reply	other threads:[~2008-10-29 10:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-26  0:57 Interesting performance quirk Peter C. Chapin
2008-10-26  2:15 ` Jeffrey Creem
2008-10-26 11:16   ` Peter C. Chapin
2008-10-26  4:57 ` tmoran
2008-10-26 11:11   ` Peter C. Chapin
2008-10-28  8:49     ` Martin
2008-10-28 11:35       ` Peter C. Chapin
2008-10-28 14:21         ` Robert A Duff
2008-10-29  1:42           ` Peter C. Chapin
2008-10-28 18:27         ` Jeffrey R. Carter
2008-10-29  1:39           ` Peter C. Chapin
2008-10-29  5:27             ` Jeffrey R. Carter
2008-10-28 23:22         ` Ludovic Brenta
2008-10-29  8:42           ` oenone
2008-10-29  9:59           ` Peter C. Chapin
2008-10-29 10:19             ` Martin [this message]
2008-11-17  6:31             ` David Thompson
2008-11-17 11:51               ` Peter C. Chapin
2008-10-29  9:54         ` Alex R. Mosteo
2008-10-30 11:16           ` Peter C. Chapin
2008-10-29 16:12         ` Colin Paul Gloster
2008-10-30 11:23           ` Peter C. Chapin
2008-10-31 13:41             ` Colin Paul Gloster
2008-11-01 15:41               ` Gene
2008-10-29 20:18 ` Florian Weimer
2008-10-30 11:15   ` Peter C. Chapin
2008-11-07  0:44 ` Randy Brukardt
2008-11-07  1:23   ` Peter C. Chapin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox