Adam D. Snyder wrote:
> After reading through "fg_props.hxx", I found that the most efficient
> was to get a property value is to use fgGetNode instead of the "fgGet"
> functions.  Is there a more efficient way to set properties, or is
> that best way to use the "fgSet" functions????

The node objects you get back from fgGetNode() (members of the
SGPropertyNode class in SimGear) have set methods, so yes.

But I think you've misunderstood a bit.  Simply replacing
fgGetFloat("/what/ever") with fgGetNode("/what/ever").getFloatValue()
gets you no speedup whatsoever (in fact, this is basically how
fgGetFloat is implemented internally).

The speedup comes from repeated operations on that property node.  If
you are going to be doing lots of operations on a property (once per
frame, for example), it pays to save the Node object somewhere.  This
avoids the overhead of parsing the string and walking the property
tree every time.

Whether the extra work is worth it or not is context dependent.  For
example, YASim does almost all of its work with the string functions,
because the property import/export overhead is tiny compared to the
work the FDM has to do to compute the values in the first place.


Flightgear-devel mailing list

Reply via email to