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 <campbell@blender.org>2022-09-06 10:27:28 +0300
committerCampbell Barton <campbell@blender.org>2022-09-07 02:02:59 +0300
commit9c4c9a889de6d25147efac33b9de8086f9c56951 (patch)
tree6ac4f5b3f720663896cbaca9695f93b519a21c03
parent6951e8890ae3d0923e377cff6023d78202d81a03 (diff)
Cleanup: use 'continue' in customdata for loop, reduce right shift
-rw-r--r--source/blender/blenkernel/intern/attribute.cc70
1 files changed, 41 insertions, 29 deletions
diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc
index b2c1382c423..941003d6c96 100644
--- a/source/blender/blenkernel/intern/attribute.cc
+++ b/source/blender/blenkernel/intern/attribute.cc
@@ -383,9 +383,12 @@ int BKE_id_attributes_length(const ID *id, eAttrDomainMask domain_mask, eCustomD
int length = 0;
for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) {
- CustomData *customdata = info[domain].customdata;
+ const CustomData *customdata = info[domain].customdata;
+ if (customdata == nullptr) {
+ continue;
+ }
- if (customdata && ((1 << (int)domain) & domain_mask)) {
+ if ((1 << (int)domain) & domain_mask) {
length += CustomData_number_of_layers_typemask(customdata, mask);
}
}
@@ -399,9 +402,11 @@ eAttrDomain BKE_id_attribute_domain(const ID *id, const CustomDataLayer *layer)
get_domains(id, info);
for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) {
- CustomData *customdata = info[domain].customdata;
- if (customdata &&
- ARRAY_HAS_ITEM((CustomDataLayer *)layer, customdata->layers, customdata->totlayer)) {
+ const CustomData *customdata = info[domain].customdata;
+ if (customdata == nullptr) {
+ continue;
+ }
+ if (ARRAY_HAS_ITEM((CustomDataLayer *)layer, customdata->layers, customdata->totlayer)) {
return static_cast<eAttrDomain>(domain);
}
}
@@ -431,9 +436,11 @@ int BKE_id_attribute_data_length(ID *id, CustomDataLayer *layer)
get_domains(id, info);
for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) {
- CustomData *customdata = info[domain].customdata;
- if (customdata &&
- ARRAY_HAS_ITEM((CustomDataLayer *)layer, customdata->layers, customdata->totlayer)) {
+ const CustomData *customdata = info[domain].customdata;
+ if (customdata == nullptr) {
+ continue;
+ }
+ if (ARRAY_HAS_ITEM((CustomDataLayer *)layer, customdata->layers, customdata->totlayer)) {
return info[domain].length;
}
}
@@ -470,18 +477,19 @@ CustomDataLayer *BKE_id_attributes_active_get(ID *id)
for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) {
CustomData *customdata = info[domain].customdata;
- if (customdata) {
- for (int i = 0; i < customdata->totlayer; i++) {
- CustomDataLayer *layer = &customdata->layers[i];
- if (CD_MASK_PROP_ALL & CD_TYPE_AS_MASK(layer->type)) {
- if (index == active_index) {
- if (BKE_attribute_allow_procedural_access(layer->name)) {
- return layer;
- }
- return nullptr;
+ if (customdata == nullptr) {
+ continue;
+ }
+ for (int i = 0; i < customdata->totlayer; i++) {
+ CustomDataLayer *layer = &customdata->layers[i];
+ if (CD_MASK_PROP_ALL & CD_TYPE_AS_MASK(layer->type)) {
+ if (index == active_index) {
+ if (BKE_attribute_allow_procedural_access(layer->name)) {
+ return layer;
}
- index++;
+ return nullptr;
}
+ index++;
}
}
}
@@ -498,16 +506,17 @@ void BKE_id_attributes_active_set(ID *id, CustomDataLayer *active_layer)
for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) {
const CustomData *customdata = info[domain].customdata;
- if (customdata) {
- for (int i = 0; i < customdata->totlayer; i++) {
- const CustomDataLayer *layer = &customdata->layers[i];
- if (layer == active_layer) {
- *BKE_id_attributes_active_index_p(id) = index;
- return;
- }
- if (CD_MASK_PROP_ALL & CD_TYPE_AS_MASK(layer->type)) {
- index++;
- }
+ if (customdata == nullptr) {
+ continue;
+ }
+ for (int i = 0; i < customdata->totlayer; i++) {
+ const CustomDataLayer *layer = &customdata->layers[i];
+ if (layer == active_layer) {
+ *BKE_id_attributes_active_index_p(id) = index;
+ return;
+ }
+ if (CD_MASK_PROP_ALL & CD_TYPE_AS_MASK(layer->type)) {
+ index++;
}
}
}
@@ -539,7 +548,10 @@ CustomData *BKE_id_attributes_iterator_next_domain(ID *id, CustomDataLayer *laye
for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) {
CustomData *customdata = info[domain].customdata;
- if (customdata && customdata->layers && customdata->totlayer) {
+ if (customdata == nullptr) {
+ continue;
+ }
+ if (customdata->layers && customdata->totlayer) {
if (customdata->layers == layers) {
use_next = true;
}