Re: Compiler String Efficiency



Again, however VB allocates strings, Space$() would be using the same code.
So it's not worth trying to work around.

I don't believe the 255 thing is an issue with VB although I would love to
see the reference that talked about that.

--
Jonathan Wood
SoftCircuits
http://www.softcircuits.com
Available for consulting: http://www.softcircuits.com/jwood/resume.htm

<dw85745@xxxxxxxxxxxxx> wrote in message
news:1126845121.461146.85540@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 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: Fast string operations
    ... Looping: I thought looping over arrays in managed code was "slow" ... array handling and such. ... The problem with TrimHelper is that it always returns a new string instance. ... The customer perceives this as a memory leak. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Discovering variable types...
    ... >- but I suppose MS expect us to use wrappers ... memory allocations for your variables from disk as well. ... >They most certainly are of fixed size, changing the size of a String ... >>me to keep buffer size and current postion right in the memory block. ...
    (comp.lang.pascal.delphi.misc)
  • Re: PChar in a user defined type access violation problem
    ... That may raise a range-check error if the file is empty. ... That class will load the entire file into memory for ... Read method to populate the string or use a TStringStream to copy the data. ... that call allocates "a buffer for a ...
    (comp.lang.pascal.delphi.misc)
  • Re: PChar in a user defined type access violation problem
    ... That may raise a range-check error if the file is empty. ... That class will load the entire file into memory for ... Read method to populate the string or use a TStringStream to copy the data. ... that call allocates "a buffer for a ...
    (alt.comp.lang.borland-delphi)
  • Re: Consuming a DLL in Visual Basic
    ... > string by using a method such as LocalFree. ... This is all about who allocates the memory and who cleans it up for strings ... newly allocated object back to a caller without creating a memory leak. ...
    (microsoft.public.dotnet.framework)

Loading