From c36d2a9a7a2a01fdaeea98270ef1eb2314dfada3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Jun 2021 14:35:01 +1000 Subject: Cleanup: rename 'count' to 'len' Reserve the term count for values that require calculation (typically linked lists). Without this convention it's difficult to know if using a length accessor function in a loop will be O(N^2) without inspecting the underlying implementation. --- source/blender/editors/transform/transform_snap_sequencer.c | 8 ++++---- source/blender/sequencer/SEQ_iterator.h | 2 +- source/blender/sequencer/intern/iterator.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/transform/transform_snap_sequencer.c b/source/blender/editors/transform/transform_snap_sequencer.c index 952b580a0a3..a180db349ff 100644 --- a/source/blender/editors/transform/transform_snap_sequencer.c +++ b/source/blender/editors/transform/transform_snap_sequencer.c @@ -52,14 +52,14 @@ typedef struct TransSeqSnapData { /** \name Snap sources * \{ */ -static int seq_get_snap_source_points_count(SeqCollection *snap_sources) +static int seq_get_snap_source_points_len(SeqCollection *snap_sources) { - return SEQ_collection_count(snap_sources) * 2; + return SEQ_collection_len(snap_sources) * 2; } static void seq_snap_source_points_alloc(TransSeqSnapData *snap_data, SeqCollection *snap_sources) { - const size_t point_count = seq_get_snap_source_points_count(snap_sources); + const size_t point_count = seq_get_snap_source_points_len(snap_sources); snap_data->source_snap_points = MEM_callocN(sizeof(int) * point_count, __func__); memset(snap_data->source_snap_points, 0, sizeof(int)); snap_data->source_snap_point_count = point_count; @@ -136,7 +136,7 @@ static int seq_get_snap_target_points_count(const TransInfo *t, count += 2; } - count *= SEQ_collection_count(snap_targets); + count *= SEQ_collection_len(snap_targets); if (snap_mode & SEQ_SNAP_TO_PLAYHEAD) { count++; diff --git a/source/blender/sequencer/SEQ_iterator.h b/source/blender/sequencer/SEQ_iterator.h index 39d8a7241fb..bdc5a093fbe 100644 --- a/source/blender/sequencer/SEQ_iterator.h +++ b/source/blender/sequencer/SEQ_iterator.h @@ -71,7 +71,7 @@ bool SEQ_iterator_ensure(SeqCollection *collection, struct Sequence *SEQ_iterator_yield(SeqIterator *iterator); SeqCollection *SEQ_collection_create(void); -uint SEQ_collection_count(SeqCollection *collection); +uint SEQ_collection_len(SeqCollection *collection); bool SEQ_collection_append_strip(struct Sequence *seq, SeqCollection *data); bool SEQ_collection_remove_strip(struct Sequence *seq, SeqCollection *data); void SEQ_collection_free(SeqCollection *collection); diff --git a/source/blender/sequencer/intern/iterator.c b/source/blender/sequencer/intern/iterator.c index 4df92ce7df4..dd343776200 100644 --- a/source/blender/sequencer/intern/iterator.c +++ b/source/blender/sequencer/intern/iterator.c @@ -117,7 +117,7 @@ SeqCollection *SEQ_collection_create(void) /** * Return number of items in collection. */ -uint SEQ_collection_count(SeqCollection *collection) +uint SEQ_collection_len(SeqCollection *collection) { return BLI_gset_len(collection->set); } -- cgit v1.2.3