[Bf-blender-cvs] [d5c8d3e6618] master: Cleanup: Avoid unnecessary/annoying type alias in asset system
Julian Eisel
noreply at git.blender.org
Fri Nov 18 12:46:02 CET 2022
Commit: d5c8d3e6618e249baf0307069c8a7292705a503c
Author: Julian Eisel
Date: Fri Nov 18 12:37:27 2022 +0100
Branches: master
https://developer.blender.org/rBd5c8d3e6618e249baf0307069c8a7292705a503c
Cleanup: Avoid unnecessary/annoying type alias in asset system
A `using FooPtr = std::unique_ptr<Foo>` isn't that useful usually, just
saves a few character stokes. It obfuscates the underlying type, which
is usually relevant information. Plus, `Ptr` for a unique pointer is
misleading (should be `UPtr` or similar).
===================================================================
M source/blender/asset_system/intern/asset_library_service.cc
M source/blender/asset_system/intern/asset_library_service.hh
===================================================================
diff --git a/source/blender/asset_system/intern/asset_library_service.cc b/source/blender/asset_system/intern/asset_library_service.cc
index 51d8e5fcee6..44c7f27af80 100644
--- a/source/blender/asset_system/intern/asset_library_service.cc
+++ b/source/blender/asset_system/intern/asset_library_service.cc
@@ -98,7 +98,8 @@ AssetLibrary *AssetLibraryService::get_asset_library_on_disk(StringRefNull top_l
std::string top_dir_trailing_slash = normalize_directory_path(top_level_directory);
- AssetLibraryPtr *lib_uptr_ptr = on_disk_libraries_.lookup_ptr(top_dir_trailing_slash);
+ std::unique_ptr<AssetLibrary> *lib_uptr_ptr = on_disk_libraries_.lookup_ptr(
+ top_dir_trailing_slash);
if (lib_uptr_ptr != nullptr) {
CLOG_INFO(&LOG, 2, "get \"%s\" (cached)", top_dir_trailing_slash.c_str());
AssetLibrary *lib = lib_uptr_ptr->get();
@@ -106,7 +107,7 @@ AssetLibrary *AssetLibraryService::get_asset_library_on_disk(StringRefNull top_l
return lib;
}
- AssetLibraryPtr lib_uptr = std::make_unique<AssetLibrary>();
+ std::unique_ptr lib_uptr = std::make_unique<AssetLibrary>();
AssetLibrary *lib = lib_uptr.get();
lib->on_blend_save_handler_register();
diff --git a/source/blender/asset_system/intern/asset_library_service.hh b/source/blender/asset_system/intern/asset_library_service.hh
index 85c08da1f0c..6045060e91e 100644
--- a/source/blender/asset_system/intern/asset_library_service.hh
+++ b/source/blender/asset_system/intern/asset_library_service.hh
@@ -31,16 +31,14 @@ namespace blender::asset_system {
* loaded from a file on disk).
*/
class AssetLibraryService {
- using AssetLibraryPtr = std::unique_ptr<AssetLibrary>;
-
static std::unique_ptr<AssetLibraryService> instance_;
/* Mapping absolute path of the library's top-level directory to the AssetLibrary instance. */
- Map<std::string, AssetLibraryPtr> on_disk_libraries_;
+ Map<std::string, std::unique_ptr<AssetLibrary>> on_disk_libraries_;
/** Library without a known path, i.e. the "Current File" library if the file isn't saved yet. If
* the file was saved, a valid path for the library can be determined and #on_disk_libraries_
* above should be used. */
- AssetLibraryPtr current_file_library_;
+ std::unique_ptr<AssetLibrary> current_file_library_;
/* Handlers for managing the life cycle of the AssetLibraryService instance. */
bCallbackFuncStore on_load_callback_store_;
More information about the Bf-blender-cvs
mailing list