Provide single-property alternatives to [gs]et_properties
#15675
Labels
Feature request
Issues that request the addition or enhancement of a feature
Performance
@ Script API
Logical extension of #14418 to the Lua sphere of things.
set_properties
andget_properties
are currently needlessly inefficient: The former will check for all possible properties. The latter will push all properties to a table. This is very wasteful if you just want to get or set a single property.The obvious solution is to provide single-property getters and setters.
Let's call them
obj:set_property(name, value)
andobj:get_property(name)
respectively.The implementation for these should probably be via an unordered map from property names to getter-setter function pointer pairs. (Or a variation of this, for example this could also alternatively use member references and property types to auto-generate these pairs at compile time.)
This could also be used to optimize the common use case of
set_properties
where you only provide a table with a few fields by iterating the table and looking up & only running corresponding setters.The text was updated successfully, but these errors were encountered: