Replace the `Ghash` `prophash` properties map in RNA containers by a
`CustomIDVectorSet` `prop_lookup_set`.
This commit also allows for runtime-defined RNA Struct types to use
`CustomIDVectorSet` for properties lookup, instead of only relying on linear
search in the ListBase property list.
NOTE: This also simplifies a bit the code compared to using Ghash, since the
string key is contained whiting the property, and not stored separately as in the
GHash. It also means that the string key (the property identifier) is 'automatically'
updated in the VectorSet when updated in the property itself. This avoids the
need to re-insert the property when its identifier string is duplicated into a new
memory address. However, modifying the property identifier would cause
undefined behavior if the property is not removed from the vector set first.
-----
While its an impractical example, the following custom PropertyGroup example shows the potential slowdowns just
of looking through the ListBase
``` py
import bpy
test_properties_script = "import bpy\nclass TestProperties(bpy.types.PropertyGroup):"
property_count=10000
for x in range(property_count):
test_properties_script+="\n prop_{0} : bpy.props.IntProperty(name=\"Prop {0}\")".format(x)
exec(test_properties_script)
class LayoutDemoPanel(bpy.types.Panel):
"""Creates a Test in the text editor side panel to test ui perfomance"""
bl_label = "Test"
bl_category = "Test"
bl_idname = "TEXT_PT_test"
bl_space_type = 'TEXT_EDITOR'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
layout.use_property_split=True
layout.use_property_decorate=False
for x in range(property_count):
row = layout.row()
row.prop(bpy.data.scenes['Scene'].test_pointer, "prop_{}".format(x))
classes = [
TestProperties,
LayoutDemoPanel,
]
if hasattr(bpy.types.Scene,'test_pointer'):
del bpy.types.Scene.test_pointer
class_register, class_unregister = bpy.utils.register_classes_factory(classes)
class_register()
bpy.types.Scene.test_pointer = bpy.props.PointerProperty(type=TestProperties)
```
<video src="attachments/95e36a02-b781-44b1-9a18-9e453f8a1432" title="2025-02-03 14-12-47.mp4" controls></video>
Pull Request: https://projects.blender.org/blender/blender/pulls/134000