Refactor: combine insert_keyframe() and insert_key_rna() into a single function #122053

Merged
Nathan Vegdahl merged 49 commits from nathanvegdahl/blender:combine_keying_functions into main 2024-06-11 16:43:08 +02:00
Showing only changes of commit 3a02ca2c0f - Show all commits

View File

@ -1039,9 +1039,7 @@ CombinedKeyingResult insert_keyframes(Main *bmain,
* we're faithfully reproducing the original behavior.
*/
eInsertKeyFlags insert_key_flags_adjusted = insert_key_flags;
if (force_all && rna_values.size() > 0 &&
(insert_key_flags & (INSERTKEY_REPLACE | INSERTKEY_AVAILABLE)) != 0)
{
if (force_all && insert_key_flags & (INSERTKEY_REPLACE | INSERTKEY_AVAILABLE)) {
nathanvegdahl marked this conversation as resolved Outdated

rna_values.size() > 0!rna_values.is_empty().

But actually that part of the condition can be entirely removed. The chance of rna_values actually being empty is minute (why is this function even getting called, in that case?), and so this only 'optimizes' away two numerical comparisons and an assignment to at_least_one_would_succeed.

`rna_values.size() > 0` → `!rna_values.is_empty()`. But actually that part of the condition can be entirely removed. The chance of `rna_values` actually being empty is minute (why is this function even getting called, in that case?), and so this only 'optimizes' away two numerical comparisons and an assignment to `at_least_one_would_succeed`.
/* Determine if at least one element would succeed getting keyed. */
nathanvegdahl marked this conversation as resolved Outdated

The != 0 can be removed, which would, for me, increase the readability of this condition.

The ` != 0` can be removed, which would, for me, increase the readability of this condition.
bool at_least_one_would_succeed = false;
for (int i = 0; i < rna_values.size(); i++) {