From 52b8d668f4d3d0a841313b678027a2d6af2fbc37 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 18 Jun 2020 18:16:51 +0200 Subject: Depsgraph: use blender::Map instead of std::map We decided to use our own map data structure in general for better readability and performance. Reviewers: sergey Differential Revision: https://developer.blender.org/D7987 --- .../intern/eval/deg_eval_runtime_backup_object.cc | 37 +++++++++------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc') diff --git a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc index 2b172f824b6..975887ae7bf 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_runtime_backup_object.cc @@ -75,7 +75,7 @@ void ObjectRuntimeBackup::backup_modifier_runtime_data(Object *object) } BLI_assert(modifier_data->orig_modifier_data != nullptr); ModifierDataBackupID modifier_data_id = create_modifier_data_id(modifier_data); - modifier_runtime_data.insert(make_pair(modifier_data_id, modifier_data->runtime)); + modifier_runtime_data.add(modifier_data_id, modifier_data->runtime); modifier_data->runtime = nullptr; } } @@ -86,7 +86,7 @@ void ObjectRuntimeBackup::backup_pose_channel_runtime_data(Object *object) LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) { /* This is nullptr in Edit mode. */ if (pchan->orig_pchan != nullptr) { - pose_channel_runtime_data[pchan->orig_pchan] = pchan->runtime; + pose_channel_runtime_data.add(pchan->orig_pchan, pchan->runtime); BKE_pose_channel_runtime_reset(&pchan->runtime); } } @@ -153,22 +153,16 @@ void ObjectRuntimeBackup::restore_modifier_runtime_data(Object *object) LISTBASE_FOREACH (ModifierData *, modifier_data, &object->modifiers) { BLI_assert(modifier_data->orig_modifier_data != nullptr); ModifierDataBackupID modifier_data_id = create_modifier_data_id(modifier_data); - ModifierRuntimeDataBackup::iterator runtime_data_iterator = modifier_runtime_data.find( - modifier_data_id); - if (runtime_data_iterator != modifier_runtime_data.end()) { - modifier_data->runtime = runtime_data_iterator->second; - runtime_data_iterator->second = nullptr; + void *runtime = modifier_runtime_data.pop_default(modifier_data_id, nullptr); + if (runtime != nullptr) { + modifier_data->runtime = runtime; } } - for (ModifierRuntimeDataBackup::value_type value : modifier_runtime_data) { - const ModifierDataBackupID modifier_data_id = value.first; - void *runtime = value.second; - if (value.second == nullptr) { - continue; - } - const ModifierTypeInfo *modifier_type_info = BKE_modifier_get_info(modifier_data_id.type); + + for (ModifierRuntimeDataBackup::Item item : modifier_runtime_data.items()) { + const ModifierTypeInfo *modifier_type_info = BKE_modifier_get_info(item.key.type); BLI_assert(modifier_type_info != nullptr); - modifier_type_info->freeRuntimeData(runtime); + modifier_type_info->freeRuntimeData(item.value); } } @@ -178,17 +172,16 @@ void ObjectRuntimeBackup::restore_pose_channel_runtime_data(Object *object) LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) { /* This is nullptr in Edit mode. */ if (pchan->orig_pchan != nullptr) { - PoseChannelRuntimeDataBackup::iterator runtime_data_iterator = - pose_channel_runtime_data.find(pchan->orig_pchan); - if (runtime_data_iterator != pose_channel_runtime_data.end()) { - pchan->runtime = runtime_data_iterator->second; - pose_channel_runtime_data.erase(runtime_data_iterator); + Optional runtime = pose_channel_runtime_data.pop_try( + pchan->orig_pchan); + if (runtime.has_value()) { + pchan->runtime = runtime.extract(); } } } } - for (PoseChannelRuntimeDataBackup::value_type &value : pose_channel_runtime_data) { - BKE_pose_channel_runtime_free(&value.second); + for (bPoseChannel_Runtime &runtime : pose_channel_runtime_data.values()) { + BKE_pose_channel_runtime_free(&runtime); } } -- cgit v1.2.3