Re: One problem I think

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Karl E. Peterson (karl_at_mvps.org)
Date: 02/02/05


Date: Wed, 2 Feb 2005 11:49:29 -0800

Les wrote:
>> One other possibility is to build the entire file into a String
>> variable in memory. When you are done, remove the last newline
>> character sequence from the last line and then simply Print that
>> String variable to the file.
>
> Well this looks as if it will work but do to the large file size I
> prefer not to work with concatenation since this would severly slow
> things down.

How large? If you're "only" talking a few hundred megs...

> It would also mean, I think, that I could not use the
> Print # command since I believe this tags a CR/LF onto the end of
> each new line of text. Hmmm I will have to rethink this a bit.
> Perhaps there is some other simple solution that evades me at the
> moment I just dont know.

I'll direct you to http://vb.mvps.org/samples/StrBldr for a dirt-simple way of
*dramatically* increasing the performance of a routine "concatenation" exercise by
preallocating the buffer and stuffing it piece by piece.

Later... Karl

-- 
[Microsoft Basic: 1976-2001, RIP]


Relevant Pages

  • Re: syntax...
    ... B&D on the part of the language designer. ... probably handle concatenation of string literals by itself, ... bitwise XOR, or if not that, then exponentiation.) ...
    (comp.lang.misc)
  • Re: Compiler String Efficiency
    ... I drew this conclusion from looking at several string concatenation ... This set me to wondering how VB was handling the memory allocation -- ... If a set amount of memory is being set aside, ...
    (microsoft.public.vb.winapi)
  • Bugs in the Module::Dependency
    ... Manifying blib/man1/pmd_indexer.plx.1 ... Use of uninitialized value in concatenation or string at ... # Failed test in t/04grapher.t at line 81. ...
    (perl.dbi.users)
  • RE: Simple regex problem has me baffled
    ... I am writing a script to analyse a log file. ... Each pair of Request and Response calls have a unique ... Use of uninitialized value in concatenation or string at ...
    (perl.beginners)
  • Re: Literal concatenation, strings vs. numbers (was: Numeric literals in other than base 10 - wa
    ... Well my take on it is that this would not be the same as string ... concatenation, the series of digits would be parsed as a single token ... digit separation can superficially resemble string concatenation if ... I would favor _ as a digit separator in Python ...
    (comp.lang.python)