Animation: minor speedup when accessing id properties
This is fundamentally quadratic code until #140907 is implemented. However, the old approach that didn't use `StringRef` was a few percent faster because it didn't have to call `strlen` as often. So this brings back a little bit of performance in cases like #140706. Pull Request: https://projects.blender.org/blender/blender/pulls/144012
This commit is contained in:
@@ -191,6 +191,13 @@ void IDP_FreeFromGroup(IDProperty *group, IDProperty *prop) ATTR_NONNULL();
|
||||
IDProperty *IDP_GetPropertyFromGroup(const IDProperty *prop,
|
||||
blender::StringRef name) ATTR_WARN_UNUSED_RESULT
|
||||
ATTR_NONNULL();
|
||||
/**
|
||||
* This is a slightly more efficient version of the function above in the when there are lots of
|
||||
* properties. It can be faster because it avoids computing the length of everything that the
|
||||
* string is compared to. Also see #140706.
|
||||
*/
|
||||
IDProperty *IDP_GetPropertyFromGroup(const IDProperty *prop,
|
||||
const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
/**
|
||||
* Same as #IDP_GetPropertyFromGroup but ensure the `type` matches.
|
||||
*/
|
||||
|
||||
@@ -769,6 +769,13 @@ IDProperty *IDP_GetPropertyFromGroup(const IDProperty *prop, const blender::Stri
|
||||
return BLI_listbase_find<IDProperty>(prop->data.group,
|
||||
[&](const IDProperty &elem) { return elem.name == name; });
|
||||
}
|
||||
|
||||
IDProperty *IDP_GetPropertyFromGroup(const IDProperty *prop, const char *name)
|
||||
{
|
||||
BLI_assert(prop->type == IDP_GROUP);
|
||||
return (IDProperty *)BLI_findstring(&prop->data.group, name, offsetof(IDProperty, name));
|
||||
}
|
||||
|
||||
IDProperty *IDP_GetPropertyTypeFromGroup(const IDProperty *prop,
|
||||
const blender::StringRef name,
|
||||
const char type)
|
||||
|
||||
Reference in New Issue
Block a user