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, T_FILL_THIS_FORM_SHORT autolearn=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail From: =?UTF-8?B?TWFya3VzIFNjaMO2cGZsaW4=?= Newsgroups: comp.lang.ada Subject: Ada.Strings.Fixed.Overwrite(), functionality & performance Date: Mon, 10 Nov 2014 11:44:30 +0100 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: MdpKeRr+sx3LK7JQiK5aNw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.giganews.com comp.lang.ada:190416 Date: 2014-11-10T11:44:30+01:00 List-Id: Hello, I'm wondering if there is an efficient way to implement procedure OVERWRITE (SOURCE : in out STRING; POSITION : in out POSITIVE; NEW_ITEM : in STRING; DROP : in TRUNCATION := RIGHT); which should behave as procedure OVERWRITE (SOURCE : in out STRING; POSITION : in out POSITIVE; NEW_ITEM : in STRING; DROP : in TRUNCATION := RIGHT) is begin ADA.STRINGS.FIXED.OVERWRITE (SOURCE, POSITION, NEW_ITEM, DROP); POSITION := POSITION + NATURAL'Min (NEW_ITEM'Length, SOURCE'Last - POSITION + 1); end; using primitives from Ada.Strings.Fixed. Currently I'm using a self-rolled version which turns out to be more than four times faster than the naive implementation above; but I'm wondering whether there isn't a better way to implement it just using primitives from Ada.Strings.Fixed. Markus