comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@on2.com (Matthew Heaney)
Subject: Re: Ada 200X
Date: 13 Jun 2003 07:20:31 -0700
Date: 2003-06-13T14:20:31+00:00	[thread overview]
Message-ID: <1ec946d1.0306130620.1d7a456a@posting.google.com> (raw)
In-Reply-To: u3f8ev87r4rhf55q2j71l6fgnk59ba2b75@4ax.com

Craig Carey <research@ijs.co.nz> wrote in message news:<u3f8ev87r4rhf55q2j71l6fgnk59ba2b75@4ax.com>...
> >
> Those packages are here:
> http://home.earthlink.net/~matthewjheaney/charles/
> http://www.ijs.co.nz/code/ada95_strings_pkg.zip (19KB
> 
> My strings package was intended to to be fast and open.
> Mr H's need not be fast (but may be). The idealism includes that of
> having functions return a private type (implying slicing is hidden
> in the package).

You can optimize string manipulation by using Resize to preallocate
the internal buffer to a specified size, and by using To_Access to
return a pointer to the internal buffer, which eliminates copying.

The To_String and Slice operations return type String, so of course
this will construct a temporary.  If this is an issue, then use
To_Access to get a pointer to the internal buffer, and then slice that
directly:

procedure Op (SC : String_Container_Subtype) is

   Slow : String := Slice (SC, Low => 10, High => 42);
   Fast : String renames To_Access (SC) (10 .. 42);
begin


> The Charles code resizes strings using a factor of 2.0 (i.e. 100%).
> I used 1.70 (70%) after some testing (in Windows 2000).

Again, by using Resize you can choose the exact size you prefer for
the internal buffer.

As a matter of fact, you could create a pool of string containers,
each of which have different internal sizes, and then use Swap to swap
in an internal buffer having the size you need.  This would eliminate
string buffer allocation entirely.

For the pool you could use a map or set, which is ordered by internal
buffer size.  Finding a buffer would only require O (log n) in the
worst case.

http://home.earthlink.net/~matthewjheaney/charles/



  reply	other threads:[~2003-06-13 14:20 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-01 21:36 Ada 200X And838N
2003-06-02  2:22 ` Bobby D. Bryant
2003-06-02  4:20 ` Robert I. Eachus
2003-06-02 11:22   ` Larry Kilgallen
2003-06-02 14:09     ` Hyman Rosen
2003-06-02 14:23       ` Vinzent Hoefler
2003-06-02 14:59         ` Hyman Rosen
2003-06-02 15:04           ` Vinzent Hoefler
2003-06-02 15:18             ` Bill Findlay
2003-06-02 15:32               ` Larry Kilgallen
2003-06-02 15:41               ` Vinzent Hoefler
2003-06-02 15:07           ` Larry Kilgallen
2003-06-02 15:04         ` Larry Kilgallen
2003-06-02 14:23     ` Robert I. Eachus
2003-06-02 14:31       ` Vinzent Hoefler
2003-06-02 15:05         ` Larry Kilgallen
2003-06-02 15:06         ` Hyman Rosen
2003-06-02 21:05         ` Robert I. Eachus
2003-06-02 22:59           ` Larry Kilgallen
2003-06-03  4:07             ` Robert I. Eachus
2003-06-03  7:52           ` Jean-Pierre Rosen
2003-06-03  9:09           ` Vinzent Hoefler
2003-06-03 14:54             ` Robert I. Eachus
2003-06-04  7:38               ` Vinzent Hoefler
2003-06-05  7:20                 ` Robert I. Eachus
2003-06-02  5:36 ` Wesley Groleau
2003-06-02  8:02 ` Preben Randhol
2003-06-02 10:50 ` Georg Bauhaus
2003-06-03  2:29 ` Steve
2003-06-03  2:45 ` Gautier Write-only
2003-06-03  8:38   ` Vinzent Hoefler
2003-06-03 11:48   ` Preben Randhol
2003-06-03 12:14     ` Lutz Donnerhacke
2003-06-03 12:35       ` Preben Randhol
2003-06-07 21:16       ` Craig Carey
2003-06-08 11:14         ` Martin Dowie
2003-06-09 14:07           ` Craig Carey
2003-06-13 14:20             ` Matthew Heaney [this message]
2003-06-13 14:00         ` Matthew Heaney
2003-06-03 17:24     ` Robert A Duff
2003-06-03 17:45       ` Preben Randhol
2003-06-03 17:48         ` Preben Randhol
2003-06-03 18:05           ` Vinzent Hoefler
2003-06-04 10:36             ` Preben Randhol
  -- strict thread matches above, loose matches on Subject: below --
2004-10-31  1:51 David Botton
2004-10-31  7:33 ` Martin Dowie
2004-10-31 18:59   ` Jeffrey Carter
2002-12-26 16:17 Ada 200x Adrian Hoe
2002-12-27 19:32 ` Randy Brukardt
2002-12-27 20:55   ` Robert A Duff
replies disabled

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