Re: Compiler String Efficiency

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



Although not all this information is available, I would consider 1 and 2
equal (1 creates a String before passing it as an argument).

3 must create two different strings. I see no reason for this.

Note: If the argument is by reference, then the address of the string is
passed. This is quite a bit more efficient that ByRef string arguments,
which cause VB to create a second string and pass the address of that.

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

<dw85745@xxxxxxxxxxxxx> wrote in message
news:1126816987.411846.61400@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> What is most efficient and what is the difference in the amount of
> string memory allocated (in the calling routine) between:
>
> 1) Passing a string directly to a function where the function requires
> a string parameter?
>
> e.g. OpenRecordSet("tblMyStuff")
>
> 2) Just allocating a VB String
>
> e.g. Dim strTableName As String
> strTableName = "tblMyStuff"
> OpenRecordSet(strTableName)
>
> 3 Allocating the exact string size
>
> e.g. Dim strTableName As String
> strTableName = Space$(10)
> strTableName = "tblMyStuff"
> OpenRecordSet(strTableName)
>
> Thanks
> David
>


.



Relevant Pages

  • Re: Elementary string-parsing
    ... "return" and passing arguments). ... stack at the end; hence they appear sort of global. ... "ValueError" if the string isn't a representation of a number? ... Convert a string or a number to floating point. ...
    (comp.lang.python)
  • Re: WindowsIdentity - Invalid token; it cannot be duplicated
    ... Because the login method will be used by asp.net application and also used ... passing the token to Login method and it tries to get the Priniciple. ... IntPtr iToken, string domainName, string userName) ... and why do you have to pass tokens around?? ...
    (microsoft.public.dotnet.security)
  • Re: C String Interop
    ... char) on passing to C. ... to C as a string, ... override the conversion for cases where that wasn't intended. ... But I would oppose special-casing of argument passing ...
    (comp.lang.fortran)
  • Re: Sockets newbie - how do I pass structured data around?
    ... >mean that passing a chunk of memory ) ... If the two systems were produced by the same code and compiler, ... end knows how long the string is and the string encoding. ... This is one case where defining user type variables like BYTE, WORD, ...
    (microsoft.public.vc.mfc)
  • Re: External API (COM) needs bstring
    ... we made a wrapper around the dll with C++ and the functions in the wrapper dll work together with the tcom-package from tcl. ... this when the API expected an int but tcom was passing a BSTR because ... You would need to force Tcl to convert this to a string internally. ... I'm not sure exactly how you would do this, but assuming $var holds ...
    (comp.lang.tcl)