1. #1

    getValue() simple question...

    I see I have various ways of getting the value of a node in the existing code.

    Is there a reason to use the DB.getValue( sourcenode, [subpath], [default] )
    versus the databasennode.getValue( )
    -> I see more of DB.getValue than node.getValue()


    Now, IF we know we do not need a "default" value for the node (as DB.getValue() can supply!) AND we already have the node, like "nodeChar" available in the method where we want to do the getValue(), does it matter which is used? Is it a matter of style or there is always an advantage to using DB.getValue() for example?

  2. #2
    In the long term, I'd like to move away from database nodes being full-fledged Lua objects; but it's a long way from that point, since every ruleset would break.

    There are a few benefits to using DB.getValue over databasenode.getValue:
    * Able to specify default value
    * Automatic check whether sourcenode is nil
    * Automatic application of subpath without having to make a separate call
    * Automatic check whether sourcenode plus subpath is nil

    Cheers,
    JPG

  3. #3
    Fantastic, thanks for the tip.

    So, if there are no advantages to using the node. I’m an old time C++ guy originally even on systems with memory measured in K so while I concede on “premature optimization is the root of all evil”, I also believe that premature pessimist ion is a thing too

    If there are two ways to do something and one is more “efficient” then unless the more efficient way is less elegant/readable I opt for that.

    I wondered if having the node already was “faster” (even if trivially) than the implicit lookup from DB. call. But it is also nice to always use a single way to access and there are times when clearly DV is way to go. Add to that the very useful knowledge that the FG devs would like to move away from this use of nodes... sold. Will opportunistically move over to that way and obviously any new reads/writes I will use this way.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Log in

Log in