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/anim_filter.c
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/anim_filter.c')
-rw-r--r--source/blender/editors/animation/anim_filter.c62
1 files changed, 27 insertions, 35 deletions
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;
+ }
}
}
}