Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-02-05 01:45:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-02-05 01:45:17 +0300
commitb62b923f544fa1df0aecd56f3568dd5185601306 (patch)
treeba53c8e44ed29a24cfb6a9d612f70638ca7f22a8 /source
parent7e850ffa733b5b54ba1e873fbf71c78bc95d80ab (diff)
Cleanup: replace inline loops with RNA_enum_from_identifier
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 447f5b4210b..f128719db19 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -595,7 +595,7 @@ static const char *rna_ui_get_enum_name(bContext *C,
const char *identifier)
{
PropertyRNA *prop = NULL;
- const EnumPropertyItem *items = NULL, *item;
+ const EnumPropertyItem *items = NULL;
bool free;
const char *name = "";
@@ -609,11 +609,9 @@ static const char *rna_ui_get_enum_name(bContext *C,
RNA_property_enum_items_gettexted(C, ptr, prop, &items, NULL, &free);
if (items) {
- for (item = items; item->identifier; item++) {
- if (item->identifier[0] && STREQ(item->identifier, identifier)) {
- name = item->name;
- break;
- }
+ const int index = RNA_enum_from_identifier(items, identifier);
+ if (index != -1) {
+ name = items[index].name;
}
if (free) {
MEM_freeN((void *)items);
@@ -629,7 +627,7 @@ static const char *rna_ui_get_enum_description(bContext *C,
const char *identifier)
{
PropertyRNA *prop = NULL;
- const EnumPropertyItem *items = NULL, *item;
+ const EnumPropertyItem *items = NULL;
bool free;
const char *desc = "";
@@ -643,11 +641,9 @@ static const char *rna_ui_get_enum_description(bContext *C,
RNA_property_enum_items_gettexted(C, ptr, prop, &items, NULL, &free);
if (items) {
- for (item = items; item->identifier; item++) {
- if (item->identifier[0] && STREQ(item->identifier, identifier)) {
- desc = item->description;
- break;
- }
+ const int index = RNA_enum_from_identifier(items, identifier);
+ if (index != -1) {
+ desc = items[index].description;
}
if (free) {
MEM_freeN((void *)items);
@@ -663,7 +659,7 @@ static int rna_ui_get_enum_icon(bContext *C,
const char *identifier)
{
PropertyRNA *prop = NULL;
- const EnumPropertyItem *items = NULL, *item;
+ const EnumPropertyItem *items = NULL;
bool free;
int icon = ICON_NONE;
@@ -677,11 +673,9 @@ static int rna_ui_get_enum_icon(bContext *C,
RNA_property_enum_items(C, ptr, prop, &items, NULL, &free);
if (items) {
- for (item = items; item->identifier; item++) {
- if (item->identifier[0] && STREQ(item->identifier, identifier)) {
- icon = item->icon;
- break;
- }
+ const int index = RNA_enum_from_identifier(items, identifier);
+ if (index != -1) {
+ icon = items[index].icon;
}
if (free) {
MEM_freeN((void *)items);