From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: Random Input-Size and recognizing ENTER-press
Date: Mon, 20 Dec 2004 06:36:22 -0800
Date: 2004-12-20T06:36:22-08:00 [thread overview]
Message-ID: <zoWdnWFB3bn-flvcRVn-sg@comcast.com> (raw)
In-Reply-To: qBhxd.4359$RH4.2409@newsread1.news.pas.earthlink.net
IMHO it's silly to worry about the number of allocations an deallocations
when you're talking about keeping up with someone typing at a keyboard
(especially at todays processor speeds).
Steve
(The Duck)
"Jeffrey Carter" <spam@spam.com> wrote in message
news:qBhxd.4359$RH4.2409@newsread1.news.pas.earthlink.net...
> Marius Amado Alves wrote:
>
>> function Get_String return String is
>> U : Unbounded_String;
>> begin
>> loop
>> Get_Immediate (C);
>> exit when C = CR;
>> Append (U, C);
>> end loop;
>> return To_String (U);
>> end;
>
> You might want to take a look at the source for Ada.Strings.Unbounded from
> GNAT before advocating an approach such as this. Every addition of a
> Character allocates a new String, copies the old String + new Character
> into the new String, and deallocates the old String. For a string of N
> Characters, that's N allocations and deallocations. Using Get_Line to
> obtain the Characters can improve that to N / Buffer'Length + 1.
>
> It's not clear that the OP really requires Get_Immediate; the only
> requirement stated is the need to read an arbitrary-length String. The
> discussion of recognizing when the Enter key is pressed is part of a
> proposed solution, not the problem.
>
> --
> Jeff Carter
> "C++: The power, elegance and simplicity of a hand grenade."
> Ole-Hjalmar Kristensen
> 90
next prev parent reply other threads:[~2004-12-20 14:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-19 8:44 Random Input-Size and recognizing ENTER-press xadian
2004-12-19 14:50 ` Marius Amado Alves
2004-12-19 16:01 ` Jeffrey Carter
2004-12-19 16:03 ` Pascal Obry
2004-12-19 23:47 ` Jeffrey Carter
2004-12-20 14:36 ` Steve [this message]
2004-12-20 23:45 ` Jeffrey Carter
2004-12-19 15:52 ` Jeffrey Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox