How to avoid copy of string variables, mappings and dyn arrays at function call?

On passing a variable to a function in CTRL (including UI), the value of the variable will copied. On using large variables (e.g. big strings, arrays or mappings), it is a good idea to use a reference variable. That would avoid the overhead of copying the variable, saves performance and reduce the memory consumption of the manager.

 

Example for using a reference:

myFunction(dyn_dyn_anytype &ddaMuchData)

 

To sign that the variable will only be used for reading and the function is not modifying its value, the reference variable can declared as const:

myFunction(const dyn_dyn_anytype &ddaMuchData)

Date added:
Last revised:
Hits:
7.970
Version:
ALL Versions
Rating:
Rating: 5.0. 1 vote(s). No rating done at all.
Your vote was '' (0 of 5) You are an anonymous user.
You may log on to do personalized votings
Click the rating bar to rate this item Please log on to do ratings
  • Notification

    FE user cannot be identified! (1403201096)

Tags:
Programming / Scripting