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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-09-01 08:23:56 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-09-01 08:23:56 +0300
commit90dac47717b12f33d5dd738da12a337cfe4f2f14 (patch)
tree9f4fff2c54dd7586c7929eedd95608dbca99ba99 /source/blender/editors/animation
parent838b6ec48af6fb767089784193d8525c5f5faf13 (diff)
Cleanup: remove redundant strstr calls
Rely on BLI_str_quoted_substrN to detect if the prefix exists since this function exists early there is no need to check before calling.
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r--source/blender/editors/animation/anim_deps.c11
-rw-r--r--source/blender/editors/animation/anim_filter.c62
-rw-r--r--source/blender/editors/animation/keyframing.c17
3 files changed, 39 insertions, 51 deletions
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 42fdb714127..2cc0f6ad288 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -207,19 +207,14 @@ static void animchan_sync_fcurve_scene(bAnimListElem *ale)
Scene *scene = (Scene *)owner_id;
FCurve *fcu = (FCurve *)ale->data;
- /* only affect if F-Curve involves sequence_editor.sequences */
- if (!strstr(fcu->rna_path, "sequences_all")) {
- return;
- }
-
- Editing *ed = SEQ_editing_get(scene, false);
-
- /* get strip name, and check if this strip is selected */
+ /* Only affect if F-Curve involves sequence_editor.sequences. */
char *seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
if (seq_name == NULL) {
return;
}
+ /* Check if this strip is selected. */
+ Editing *ed = SEQ_editing_get(scene, false);
Sequence *seq = SEQ_get_sequence_by_name(ed->seqbasep, seq_name, false);
MEM_freeN(seq_name);
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 020518b5813..2252fc4fcbc 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1061,20 +1061,16 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
if (GS(owner_id->name) == ID_OB) {
Object *ob = (Object *)owner_id;
+ char *bone_name;
- /* only consider if F-Curve involves pose.bones */
- if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) {
-
- /* get bone-name, and check if this bone is selected */
- bPoseChannel *pchan = NULL;
- char *bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
- if (bone_name) {
- pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- MEM_freeN(bone_name);
- }
+ /* Only consider if F-Curve involves `pose.bones`. */
+ if (fcu->rna_path && (bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones["))) {
+ /* Get bone-name, and check if this bone is selected. */
+ bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
+ MEM_freeN(bone_name);
/* check whether to continue or skip */
- if ((pchan) && (pchan->bone)) {
+ if (pchan && pchan->bone) {
/* If only visible channels,
* skip if bone not visible unless user wants channels from hidden data too. */
if (skip_hidden) {
@@ -1101,22 +1097,19 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
}
else if (GS(owner_id->name) == ID_SCE) {
Scene *scene = (Scene *)owner_id;
+ char *seq_name;
- /* only consider if F-Curve involves sequence_editor.sequences */
- if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) {
- Editing *ed = SEQ_editing_get(scene, false);
+ /* Only consider if F-Curve involves `sequence_editor.sequences`. */
+ if (fcu->rna_path && (seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all["))) {
+ /* Get strip name, and check if this strip is selected. */
Sequence *seq = NULL;
-
+ Editing *ed = SEQ_editing_get(scene, false);
if (ed) {
- /* get strip name, and check if this strip is selected */
- char *seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
- if (seq_name) {
- seq = SEQ_get_sequence_by_name(ed->seqbasep, seq_name, false);
- MEM_freeN(seq_name);
- }
+ seq = SEQ_get_sequence_by_name(ed->seqbasep, seq_name, false);
}
+ MEM_freeN(seq_name);
- /* can only add this F-Curve if it is selected */
+ /* Can only add this F-Curve if it is selected. */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
if ((seq == NULL) || (seq->flag & SELECT) == 0) {
return true;
@@ -1126,22 +1119,21 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
}
else if (GS(owner_id->name) == ID_NT) {
bNodeTree *ntree = (bNodeTree *)owner_id;
+ char *node_name;
- /* check for selected nodes */
- if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) {
+ /* Check for selected nodes. */
+ if (fcu->rna_path && (node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes["))) {
bNode *node = NULL;
+ /* Get strip name, and check if this strip is selected. */
+ node = nodeFindNodebyName(ntree, node_name);
+ MEM_freeN(node_name);
- /* get strip name, and check if this strip is selected */
- char *node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
- if (node_name) {
- node = nodeFindNodebyName(ntree, node_name);
- MEM_freeN(node_name);
- }
-
- /* can only add this F-Curve if it is selected */
- if (ads->filterflag & ADS_FILTER_ONLYSEL) {
- if ((node) && (node->flag & NODE_SELECT) == 0) {
- return true;
+ /* Can only add this F-Curve if it is selected. */
+ if (node) {
+ if (ads->filterflag & ADS_FILTER_ONLYSEL) {
+ if ((node->flag & NODE_SELECT) == 0) {
+ return true;
+ }
}
}
}
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 0a499232ba9..292d665caca 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -2216,9 +2216,8 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
/* in pose mode, only delete the F-Curve if it belongs to a selected bone */
if (ob->mode & OB_MODE_POSE) {
- if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones[")) {
-
- /* get bone-name, and check if this bone is selected */
+ if (fcu->rna_path) {
+ /* Get bone-name, and check if this bone is selected. */
char *bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
if (bone_name) {
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
@@ -2320,16 +2319,18 @@ static int delete_key_v3d_without_keying_set(bContext *C, wmOperator *op)
* NOTE: This is only done in pose mode.
* In object mode, we're dealing with the entire object.
*/
- if ((ob->mode & OB_MODE_POSE) && strstr(fcu->rna_path, "pose.bones[\"")) {
+ if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan = NULL;
- /* get bone-name, and check if this bone is selected */
+ /* Get bone-name, and check if this bone is selected. */
char *bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
- if (bone_name) {
- pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- MEM_freeN(bone_name);
+ if (bone_name == NULL) {
+ continue;
}
+ pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
+ MEM_freeN(bone_name);
+
/* skip if bone is not selected */
if ((pchan) && (pchan->bone)) {
/* bones are only selected/editable if visible... */