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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,76ec5d55630beb71 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-13 07:00:40 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Ada 200X Date: 13 Jun 2003 07:00:39 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0306130600.48c289f3@posting.google.com> References: <3EDC0BE6.42300129@somewhere.nil> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1055512839 12039 127.0.0.1 (13 Jun 2003 14:00:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 13 Jun 2003 14:00:39 GMT Xref: archiver1.google.com comp.lang.ada:39116 Date: 2003-06-13T14:00:39+00:00 List-Id: Craig Carey wrote in message news:... > > Some sample techniques for speeding up some Ada 95 programs: At least in Charles, you can optimize string and vector container manipulation by calling Resize, which preallocates the internal buffer. This is useful if you know the ultimate size of the collection apriori: procedure Op (S : in out String_Container_Subtype) is begin Resize (S, Size => 80); //for example Append (S, "first"); Append (S, "second"); ... end Op; Both the string and vector containers have a To_Access function, which returns a pointer to the internal buffer. This allows you to eliminate copying. For example, instead of this: procedure Op (S : in String_Container_Subtype) is begin Put_Line (To_String (S)); -- not as efficient as below end; do this instead, if you're really concerned about efficiency: procedure Op (S : in String_Container_Subtype) is Line : String renames To_Access (S) (1 .. Length (S)); begin Put_Line (Line); end; The string container package guarantees that To_Access always returns a non-null access object. The combination of Resize and To_Access should improve efficiency.