diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2021-12-08 19:56:13 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-12-08 20:21:57 +0300 |
commit | 6ebc581b52e9e5721833a528f6a536a80b615db2 (patch) | |
tree | 7ab43cfbb3cd2f5a0d988febb7cf6a6295594dd7 /source/blender | |
parent | 069d63561a4ca07aec94ce003d71bd090ebbb887 (diff) |
Cleanup: Avoid lookup the same property string multiple times
This is a micro-optimization that is useful for operators with many properties.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 4 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 32 |
2 files changed, 21 insertions, 15 deletions
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index a842975a76e..c2ff095904d 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -393,11 +393,11 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve RNA_property_is_set(op->ptr, prop)) { float values[4] = {0}; /* in case value isn't length 4, avoid uninitialized memory. */ if (RNA_property_array_check(prop)) { - RNA_float_get_array(op->ptr, "value", values); + RNA_property_float_get_array(op->ptr, prop, values); t_values_set_is_array = true; } else { - values[0] = RNA_float_get(op->ptr, "value"); + values[0] = RNA_property_float_get(op->ptr, prop); } if (t->flag & T_MODAL) { diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 71f26ef0594..a09078a8222 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -708,33 +708,39 @@ void initSnapping(TransInfo *t, wmOperator *op) resetSnapping(t); /* if snap property exists */ - if (op && RNA_struct_find_property(op->ptr, "snap") && - RNA_struct_property_is_set(op->ptr, "snap")) { - if (RNA_boolean_get(op->ptr, "snap")) { + PropertyRNA *prop; + if (op && (prop = RNA_struct_find_property(op->ptr, "snap")) && + RNA_property_is_set(op->ptr, prop)) { + if (RNA_property_boolean_get(op->ptr, prop)) { t->modifiers |= MOD_SNAP; - if (RNA_struct_property_is_set(op->ptr, "snap_target")) { - snap_target = RNA_enum_get(op->ptr, "snap_target"); + if ((prop = RNA_struct_find_property(op->ptr, "snap_target")) && + RNA_property_is_set(op->ptr, prop)) { + snap_target = RNA_property_enum_get(op->ptr, prop); } - if (RNA_struct_property_is_set(op->ptr, "snap_point")) { - RNA_float_get_array(op->ptr, "snap_point", t->tsnap.snapPoint); + if ((prop = RNA_struct_find_property(op->ptr, "snap_point")) && + RNA_property_is_set(op->ptr, prop)) { + RNA_property_float_get_array(op->ptr, prop, t->tsnap.snapPoint); t->tsnap.status |= SNAP_FORCED | POINT_INIT; } /* snap align only defined in specific cases */ - if (RNA_struct_find_property(op->ptr, "snap_align")) { - t->tsnap.align = RNA_boolean_get(op->ptr, "snap_align"); + if ((prop = RNA_struct_find_property(op->ptr, "snap_align")) && + RNA_property_is_set(op->ptr, prop)) { + t->tsnap.align = RNA_property_boolean_get(op->ptr, prop); RNA_float_get_array(op->ptr, "snap_normal", t->tsnap.snapNormal); normalize_v3(t->tsnap.snapNormal); } - if (RNA_struct_find_property(op->ptr, "use_snap_project")) { - t->tsnap.project = RNA_boolean_get(op->ptr, "use_snap_project"); + if ((prop = RNA_struct_find_property(op->ptr, "use_snap_project")) && + RNA_property_is_set(op->ptr, prop)) { + t->tsnap.project = RNA_property_boolean_get(op->ptr, prop); } - if (RNA_struct_find_property(op->ptr, "use_snap_self")) { - t->tsnap.snap_self = RNA_boolean_get(op->ptr, "use_snap_self"); + if ((prop = RNA_struct_find_property(op->ptr, "use_snap_self")) && + RNA_property_is_set(op->ptr, prop)) { + t->tsnap.snap_self = RNA_property_boolean_get(op->ptr, prop); } } } |