diff options
author | Campbell Barton <campbell@blender.org> | 2022-02-15 12:07:54 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-02-15 12:13:00 +0300 |
commit | 07ed869b94fa8acf18d64864c6d8662bfbec33dd (patch) | |
tree | 8ff07b7983bb693c704550104fae0cc3c1a4dfde /source/blender/python/intern/bpy_rna.c | |
parent | 4637e83990babd208e932e7f7b09a86e1de2e4fd (diff) |
RNA: add RNA_collection_is_empty & RNA_property_collection_is_empty
Some collections needed to be iterated over to count their length.
Provide a function to check if the collection is empty to avoid this.
Diffstat (limited to 'source/blender/python/intern/bpy_rna.c')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 2e0dfc515d1..316cfe4d8b1 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -2192,16 +2192,9 @@ static int pyrna_prop_array_bool(BPy_PropertyRNA *self) static int pyrna_prop_collection_bool(BPy_PropertyRNA *self) { - /* No callback defined, just iterate and find the nth item. */ - CollectionPropertyIterator iter; - int test; - PYRNA_PROP_CHECK_INT(self); - RNA_property_collection_begin(&self->ptr, self->prop, &iter); - test = iter.valid; - RNA_property_collection_end(&iter); - return test; + return !RNA_property_collection_is_empty(&self->ptr, self->prop); } /* notice getting the length of the collection is avoided unless negative |