Re: String filtering
- From: "Jeffrey R. Carter" <spam@xxxxxxxx>
- Date: Wed, 28 Sep 2005 18:32:35 GMT
David Trudgett wrote:
Yes, it does seem odd. As it happens, the code is easier and shorter
that way, but <<New_Str := To_Unbounded_String("");>> might free
storage in some implementations, so I created a new version using
Replace_Element instead.
Well, no (if I interpret your use of "that way" the same way you meant it). It's shorter and easier to use the default initial value of null string, and then Append to it. Initializing it to an uninitialized string of the known result length, then replacing that by a null string, and then appending, is longer, harder, and makes the reader stop and say "Huh?"
Your version using Replace_Element is more along the lines that I was suggesting.
Repeated deletes would cause a lot of copying (though not a problem for my particular purposes at present).
Probably (a version based on a linked list of Characters would be optimized for Delete, but less than optimal for other operations :). The question is which version is clearest for your system. If the clean up in place is the clearest, then you have the questions of what the timing requirements are for your system, and whether using Delete causes the system to fail to meet those requirements.
Now, go away or I shall taunt you a second time! ;-)
Taunt away! I'm not planning on going anywhere, obnoxious French chevalier!
-- Jeff Carter "You tiny-brained wipers of other people's bottoms!" Monty Python & the Holy Grail 18 .
- References:
- String filtering
- From: David Trudgett
- Re: String filtering
- From: David Trudgett
- Re: String filtering
- From: Jeffrey R. Carter
- Re: String filtering
- From: David Trudgett
- String filtering
- Prev by Date: Re: String filtering
- Next by Date: Re: GNAT GPL - Anonymous Access Type
- Previous by thread: Re: String filtering
- Next by thread: Re: String filtering
- Index(es):
Relevant Pages
|