Stewart Andreason wrote:
> If accessing temp1 _is_ faster than .getValue, then at 2 or 3
> accesses, I imagine it becomes faster to do the above?

Yes, it's definitely faster, because there's less work to do.
Evaluating the expression "temp1" requires pushing the symbol value (a
string) onto the stack, and executing OP_LOCAL which does a hash table
lookup to find the value in the namespace list and leave it on the
stack for the next bit of code to use.

Evaluating "node.getValue()" requires:

  Pushing the symbol "node" onto the stack
  Executing OP_LOCAL to look it up
  Pushing the symbol "getValue" onto the stack
  Executing OP_MEMBER to look it up in the object
  Executing OP_CALL to call it as a function
  Finally (!) calling the C++ property node function
  Turn the output node into a Nasal object and leave it on the stack.

That said, you really don't want to be designing your scripts around
raw, low-level performance issues.  Write your code to be readable,
not blazingly fast.  In general "altitude" is more readable than


This email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>
Flightgear-devel mailing list

Reply via email to