Jump to content

Recommended Posts

Posted

I am concerned about the efficiency of passing large data structures as parameters to functions. Am I right in assuming that passing a parameter by reference (i.e. using the ByRef keyword) will not perform a copy? If the parameter is passed without the ByRef keyword is a copy performed?

Thanks in anticipation

GrahamS

Posted

ByRef uses the original variable, no copy is performed. Otherwise, a local (to the function) copy is created for the scope of the function and is destroyed when the function exits.

  • Administrators
Posted

Unless you have a good reason not to, always pass arrays by reference - the performance difference is massive (hence why not many languages allow you to pass arrays any other way)


 

Posted

That's why I wanted confirmation about my assumption.

Would it not be a good idea to add this to the help file?

BTW I once was called in to troubleshoot a hard real time project, written in C, that had major performance problems. They were passing 1400 byte messages by value, up to 50 times per message! The fix gained an order of magnitude improvement.

GrahamS

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...