diff options
author | Hans Goudey <h.goudey@me.com> | 2021-02-18 01:42:20 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-02-18 01:42:20 +0300 |
commit | 5fef212e3185b23051da6889d4fe08645249d217 (patch) | |
tree | 274c816eb8a94d5dbb066d73804c20f26e5e254e /source/blender/editors/interface/interface_utils.c | |
parent | fd75f7c135747b6fb4e53a0a277ad432ec7bfa08 (diff) |
Cleanup: Use const argument, decrease variable scope
Diffstat (limited to 'source/blender/editors/interface/interface_utils.c')
-rw-r--r-- | source/blender/editors/interface/interface_utils.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index af058264f25..824fb6272f6 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -511,21 +511,15 @@ void ui_rna_collection_search_update_fn(const struct bContext *C, } /***************************** ID Utilities *******************************/ -int UI_icon_from_id(ID *id) +int UI_icon_from_id(const ID *id) { - Object *ob; - PointerRNA ptr; - short idcode; - if (id == NULL) { return ICON_NONE; } - idcode = GS(id->name); - /* exception for objects */ - if (idcode == ID_OB) { - ob = (Object *)id; + if (GS(id->name) == ID_OB) { + Object *ob = (Object *)id; if (ob->type == OB_EMPTY) { return ICON_EMPTY_DATA; @@ -535,7 +529,8 @@ int UI_icon_from_id(ID *id) /* otherwise get it through RNA, creating the pointer * will set the right type, also with subclassing */ - RNA_id_pointer_create(id, &ptr); + PointerRNA ptr; + RNA_id_pointer_create((ID *)id, &ptr); return (ptr.type) ? RNA_struct_ui_icon(ptr.type) : ICON_NONE; } |