WIP: use generic copy-on-write system to avoid unnecessary data copies #104470

Closed
Jacques Lucke wants to merge 50 commits from JacquesLucke/blender:temp-copy-on-write-customdata into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 9 additions and 5 deletions
Showing only changes of commit 66b4840d90 - Show all commits

View File

@ -2436,13 +2436,17 @@ static void customData_free_layer__internal(CustomDataLayer *layer, const int to
}
layer->anonymous_id = nullptr;
}
if (layer->data) {
const eCustomDataType type = eCustomDataType(layer->type);
if (layer->cow == nullptr) {
const eCustomDataType type = eCustomDataType(layer->type);
if (layer->cow == nullptr) {
if (layer->data) {
free_layer_data(type, layer->data, totelem);
}
else if (BLI_cow_user_remove(layer->cow)) {
free_layer_data(type, layer->data, totelem);
}
else {
if (BLI_cow_user_remove(layer->cow)) {
if (layer->data) {
free_layer_data(type, layer->data, totelem);
}
BLI_cow_free(layer->cow);
}
}