Re: Compiler String Efficiency

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I drew this conclusion from looking at several string concatenation
routines where the speed was significantly increased in VB by
preallocating memory (Space$) for the string with a buffer whereas by
concatenating the strings themselves resulted in much slower
concatenation.

Granted in concatenation the compiler doesn't know the size of the
resulting string.

This set me to wondering how VB was handling the memory allocation --
that is, automatically setting aside a set amount of memory (e.g. 255)
and then reducing OR
determining the string Len, and then allocating the required amount of
memory.

If a set amount of memory is being set aside, then the buffer should be
faster and more efficient.

.



Relevant Pages

  • Re: One problem I think
    ... >> One other possibility is to build the entire file into a String ... >> variable in memory. ... When you are done, remove the last newline ... *dramatically* increasing the performance of a routine "concatenation" exercise by ...
    (microsoft.public.vb.general.discussion)
  • Re: Where is stringbuilder?
    ... allocated that can accommodate the new string. ... The memory used by the original s is then abandoned, ... memory allocations required, and the amount of work needed by the ... If one /knows/ that one will be concatenation a whole load of strings, ...
    (alt.comp.lang.borland-delphi)
  • Re: Compiler String Efficiency
    ... Again, however VB allocates strings, Space$would be using the same code. ... > preallocating memory for the string with a buffer whereas by ... > If a set amount of memory is being set aside, ...
    (microsoft.public.vb.winapi)
  • Re: Does VBscript support " & _" for long strings?
    ... you are iteratively appending values to a string. ... to be allotted in order to perform the concatenation. ... Join, on the other hand, walks all strings in the array ... and then needs to allot memory only ...
    (microsoft.public.scripting.vbscript)
  • Re: MASD syntax to load the current address in C.A at runtime
    ... so my memory on A=PC is not as good. ... CODE object, the CRC on the CODE object will change. ... easier to store individual pieces as the time string was built. ...
    (comp.sys.hp48)