diff --git a/source/blender/blenkernel/BKE_idprop.hh b/source/blender/blenkernel/BKE_idprop.hh index 4340ef542d8..ac3798894f9 100644 --- a/source/blender/blenkernel/BKE_idprop.hh +++ b/source/blender/blenkernel/BKE_idprop.hh @@ -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. */ diff --git a/source/blender/blenkernel/intern/idprop.cc b/source/blender/blenkernel/intern/idprop.cc index 1b0fccaf41b..2012bcee924 100644 --- a/source/blender/blenkernel/intern/idprop.cc +++ b/source/blender/blenkernel/intern/idprop.cc @@ -769,6 +769,13 @@ IDProperty *IDP_GetPropertyFromGroup(const IDProperty *prop, const blender::Stri return BLI_listbase_find(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)