Cleanup: replace inline loops with RNA_enum_from_identifier
This commit is contained in:
@@ -595,7 +595,7 @@ static const char *rna_ui_get_enum_name(bContext *C,
|
|||||||
const char *identifier)
|
const char *identifier)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop = NULL;
|
PropertyRNA *prop = NULL;
|
||||||
const EnumPropertyItem *items = NULL, *item;
|
const EnumPropertyItem *items = NULL;
|
||||||
bool free;
|
bool free;
|
||||||
const char *name = "";
|
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);
|
RNA_property_enum_items_gettexted(C, ptr, prop, &items, NULL, &free);
|
||||||
|
|
||||||
if (items) {
|
if (items) {
|
||||||
for (item = items; item->identifier; item++) {
|
const int index = RNA_enum_from_identifier(items, identifier);
|
||||||
if (item->identifier[0] && STREQ(item->identifier, identifier)) {
|
if (index != -1) {
|
||||||
name = item->name;
|
name = items[index].name;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (free) {
|
if (free) {
|
||||||
MEM_freeN((void *)items);
|
MEM_freeN((void *)items);
|
||||||
@@ -629,7 +627,7 @@ static const char *rna_ui_get_enum_description(bContext *C,
|
|||||||
const char *identifier)
|
const char *identifier)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop = NULL;
|
PropertyRNA *prop = NULL;
|
||||||
const EnumPropertyItem *items = NULL, *item;
|
const EnumPropertyItem *items = NULL;
|
||||||
bool free;
|
bool free;
|
||||||
const char *desc = "";
|
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);
|
RNA_property_enum_items_gettexted(C, ptr, prop, &items, NULL, &free);
|
||||||
|
|
||||||
if (items) {
|
if (items) {
|
||||||
for (item = items; item->identifier; item++) {
|
const int index = RNA_enum_from_identifier(items, identifier);
|
||||||
if (item->identifier[0] && STREQ(item->identifier, identifier)) {
|
if (index != -1) {
|
||||||
desc = item->description;
|
desc = items[index].description;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (free) {
|
if (free) {
|
||||||
MEM_freeN((void *)items);
|
MEM_freeN((void *)items);
|
||||||
@@ -663,7 +659,7 @@ static int rna_ui_get_enum_icon(bContext *C,
|
|||||||
const char *identifier)
|
const char *identifier)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop = NULL;
|
PropertyRNA *prop = NULL;
|
||||||
const EnumPropertyItem *items = NULL, *item;
|
const EnumPropertyItem *items = NULL;
|
||||||
bool free;
|
bool free;
|
||||||
int icon = ICON_NONE;
|
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);
|
RNA_property_enum_items(C, ptr, prop, &items, NULL, &free);
|
||||||
|
|
||||||
if (items) {
|
if (items) {
|
||||||
for (item = items; item->identifier; item++) {
|
const int index = RNA_enum_from_identifier(items, identifier);
|
||||||
if (item->identifier[0] && STREQ(item->identifier, identifier)) {
|
if (index != -1) {
|
||||||
icon = item->icon;
|
icon = items[index].icon;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (free) {
|
if (free) {
|
||||||
MEM_freeN((void *)items);
|
MEM_freeN((void *)items);
|
||||||
|
Reference in New Issue
Block a user