comp.lang.ada
 help / color / mirror / Atom feed
From: "Markus Schöpflin" <no.spam@spam.spam>
Subject: Ada.Strings.Fixed.Overwrite(), functionality & performance
Date: Mon, 10 Nov 2014 11:44:30 +0100
Date: 2014-11-10T11:44:30+01:00	[thread overview]
Message-ID: <m3q4uc$el0$1@speranza.aioe.org> (raw)

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


                 reply	other threads:[~2014-11-10 10:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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