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-Thread: 103376,64b29dfa2220a59f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Reserve_Capacity for Unbounded_String? Date: Sun, 22 Jul 2007 17:32:06 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1185134043.892012.217560@n2g2000hse.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1185139926 18806 192.74.137.71 (22 Jul 2007 21:32:06 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 22 Jul 2007 21:32:06 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:+qGL/6OJZ81LhVSssTqLrajdTno= Xref: g2news1.google.com comp.lang.ada:16537 Date: 2007-07-22T17:32:06-04:00 List-Id: Maciej Sobczak writes: > Why there is no Reserve_Capacity for Unbounded_String? Probably for historical reasons. > Sounds like a natural idea to me. Yes. > How to emulate it? > > The following seems to work fine: > > declare > S : Unbounded_String; > My_Capacity : constant := 1000; > begin > S := To_Unbounded_String (My_Capacity); I would write To_Unbounded_String (Length => My_Capacity); to make it clear which To_Unbounded_String you're calling. > Delete (Source => S, From => 1, Through => My_Capacity); > -- ... > end; > > "Seems to work fine" means that after the above two operations the > string is logically empty, but the subsequent appends run faster > (which is actually the original motivation). How much faster (I'm curious)? > Is this a reasonable approach if performance is of concern? I think so. - Bob