Re: String filtering



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
.



Relevant Pages

  • Re: Parsing / " characters
    ... have the rest of the code to append the ... - JCL inserts that string at the start of every program, ... >>the code associated with that program - in exact order, ... >>Dim db As Database, tdf As TableDef ...
    (microsoft.public.access.externaldata)
  • Re: Parsing / " characters
    ... create a new record in table TTT containing the string ... >I can append ALL the records from the ... >Dim db As Database, tdf As TableDef ... >> Dim lngFN as Long ...
    (microsoft.public.access.externaldata)
  • Re: Fastest way to append text to a TextBox
    ... What's the fastest way to append text to a TextBox? ... CPU and, even if I limit the TextBox to just 30KB of text, it takes over ... Private Sub AppendText(ByVal sText As String) ... Dim iLen As Integer = .Text.Length + sText.Length ...
    (microsoft.public.dotnet.languages.vb)
  • RE: SaveWorkbookAsToday()
    ... Create a string variables for the day and convert your date to the format you ... Then append or concatenate the string date where necessary in the file name. ... Dim DateFormat As String ...
    (microsoft.public.excel.programming)
  • Re: Problem appending Objects to File
    ... // test ability to append to a serialized object stream ... * write some string objects to serialized file ... ObjectOutputStream oos = new ObjectOutputStream; ...
    (comp.lang.java.programmer)