[Bf-blender-cvs] [1db42c9b796] master: Address warning about breaking copy elision of temporary object

Julian Eisel noreply at git.blender.org
Tue Oct 12 16:38:51 CEST 2021


Commit: 1db42c9b7967507d5d3ac688fb1a4a36bfac5f95
Author: Julian Eisel
Date:   Tue Oct 12 16:23:57 2021 +0200
Branches: master
https://developer.blender.org/rB1db42c9b7967507d5d3ac688fb1a4a36bfac5f95

Address warning about breaking copy elision of temporary object

Using `std::move()` on temporary objects prevents copy elision done by
compilers. Apple Clang warns about this.

Generally `std::move()` should be used sparingly:
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines

===================================================================

M	source/blender/blenkernel/intern/asset_catalog.cc

===================================================================

diff --git a/source/blender/blenkernel/intern/asset_catalog.cc b/source/blender/blenkernel/intern/asset_catalog.cc
index 2e01d3cdcea..f66fda1a0bc 100644
--- a/source/blender/blenkernel/intern/asset_catalog.cc
+++ b/source/blender/blenkernel/intern/asset_catalog.cc
@@ -484,7 +484,7 @@ void AssetCatalogService::undo()
   BLI_assert_msg(is_undo_possbile(), "Undo stack is empty");
 
   redo_snapshots_.append(std::move(catalog_collection_));
-  catalog_collection_ = std::move(undo_snapshots_.pop_last());
+  catalog_collection_ = undo_snapshots_.pop_last();
   rebuild_tree();
 }
 
@@ -493,7 +493,7 @@ void AssetCatalogService::redo()
   BLI_assert_msg(is_redo_possbile(), "Redo stack is empty");
 
   undo_snapshots_.append(std::move(catalog_collection_));
-  catalog_collection_ = std::move(redo_snapshots_.pop_last());
+  catalog_collection_ = redo_snapshots_.pop_last();
   rebuild_tree();
 }
 
@@ -510,12 +510,12 @@ std::unique_ptr<AssetCatalogCollection> AssetCatalogCollection::deep_copy() cons
 {
   auto copy = std::make_unique<AssetCatalogCollection>();
 
-  copy->catalogs_ = std::move(copy_catalog_map(this->catalogs_));
-  copy->deleted_catalogs_ = std::move(copy_catalog_map(this->deleted_catalogs_));
+  copy->catalogs_ = copy_catalog_map(this->catalogs_);
+  copy->deleted_catalogs_ = copy_catalog_map(this->deleted_catalogs_);
 
   if (catalog_definition_file_) {
-    copy->catalog_definition_file_ = std::move(
-        catalog_definition_file_->copy_and_remap(copy->catalogs_, copy->deleted_catalogs_));
+    copy->catalog_definition_file_ = catalog_definition_file_->copy_and_remap(
+        copy->catalogs_, copy->deleted_catalogs_);
   }
 
   return copy;



More information about the Bf-blender-cvs mailing list