New Premium Module: Tyrants of the Moonsea! Read More
NWScript function efficiencies
I'm a little curious to see if there's any information on how efficient some of the functions in NWScript are. I've heard that local variables are stored on objects as a linked list, for instance, so I'd imagine that GetLocalString and SetLocalString are O(N).
There are a lot of functions in NWScript, so to limit my query down, I'm particularly interested in functions that perform searches of objects or creatures. Specifically:
- GetNearestCreature / GetNearestCreatureToLocaiton
- GetFirstObjectInShape / GetNextObjectInShape
How efficient is it to find an object by a tag? Do tags get a O(1) hashtable lookup? Some sort of O(log N) tree? Or is it another linked list?
How efficient is it to search for nearest creatures or objects? Is it always an O(N) iteration over all objects in the area? Is it an iteration over a list restricted by type? Is there something more sophisticated like an quadtree lookup?
If a Beamdog dev could weigh in, I'd be very grateful!