Reply To: Getting Blackboard values by hash instead of string for performance?

NodeCanvas Forums Support Getting Blackboard values by hash instead of string for performance? Reply To: Getting Blackboard values by hash instead of string for performance?

#15659
Gavalakis
Keymaster

Hello,

There is no support for getting a variable by a hash (int). If you are concerned about the performance of creating a string each time you want to access a variable (creation of a string is where the performance cost will be), then you can either:

A) Create a constant string that has the name of the variable you want to access and use that constant instead of creating a new string each timer you want to access a Blackboard Variable.

OR

B) Get a reference of the Variable object (Blackboard.GetVariable) and store it in a field. Then directly work with that variable reference (GetValue, SetValue) instead of finding the Variable through Blackboard each time you want to access it. This is the better option if you want to access a variable very frequently.

Please note that these optimizations already happen in the context of accessing variables in Task and Nodes via BBParameters. So these are only relevant if you want to access blackboard variables manually and very frequently. If you do not access variables manually and very frequently then I think that you should really worry about the above optimizations 🙂

Let me know if that helps.
Thank you!

Join us on Discord: https://discord.gg/97q2Rjh