[Bf-blender-cvs] [01e479b7904] master: Cleanup: simplify removing asset code

Jacques Lucke noreply at git.blender.org
Wed Nov 23 10:04:35 CET 2022


Commit: 01e479b79041369e28a38cc8e2c844af0240e385
Author: Jacques Lucke
Date:   Wed Nov 23 10:04:24 2022 +0100
Branches: master
https://developer.blender.org/rB01e479b79041369e28a38cc8e2c844af0240e385

Cleanup: simplify removing asset code

Differential Revision: https://developer.blender.org/D16570

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

M	source/blender/asset_system/intern/asset_storage.cc

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

diff --git a/source/blender/asset_system/intern/asset_storage.cc b/source/blender/asset_system/intern/asset_storage.cc
index d4dcc0ce73c..d21468a9c8e 100644
--- a/source/blender/asset_system/intern/asset_storage.cc
+++ b/source/blender/asset_system/intern/asset_storage.cc
@@ -29,29 +29,10 @@ AssetRepresentation &AssetStorage::add_external_asset(StringRef name,
 
 bool AssetStorage::remove_asset(AssetRepresentation &asset)
 {
-  auto remove_if_contained_fn = [&asset](StorageT &storage) {
-    /* Create a "fake" unique_ptr to figure out the hash for the pointed to asset representation.
-     * The standard requires that this is the same for all unique_ptr's wrapping the same address.
-     */
-    std::unique_ptr<AssetRepresentation> fake_asset_ptr{&asset};
-
-    const std::unique_ptr<AssetRepresentation> *real_asset_ptr = storage.lookup_key_ptr_as(
-        fake_asset_ptr);
-    /* Make sure the contained storage is not destructed. */
-    fake_asset_ptr.release();
-
-    if (!real_asset_ptr) {
-      return false;
-    }
-
-    storage.remove_contained(*real_asset_ptr);
-    return true;
-  };
-
-  if (remove_if_contained_fn(local_id_assets_)) {
+  if (local_id_assets_.remove_as(&asset)) {
     return true;
   }
-  return remove_if_contained_fn(external_assets_);
+  return external_assets_.remove_as(&asset);
 }
 
 void AssetStorage::remap_ids_and_remove_invalid(const IDRemapper &mappings)



More information about the Bf-blender-cvs mailing list