[Bf-blender-cvs] [fd46b5e9fea] functions: remove lazy init usage

Jacques Lucke noreply at git.blender.org
Thu Feb 13 18:59:09 CET 2020


Commit: fd46b5e9fea1b4e1d8568cfb6c9c65f39ed22a0c
Author: Jacques Lucke
Date:   Thu Feb 13 18:33:56 2020 +0100
Branches: functions
https://developer.blender.org/rBfd46b5e9fea1b4e1d8568cfb6c9c65f39ed22a0c

remove lazy init usage

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

M	source/blender/blenlib/BLI_lazy_init_cxx.h
M	source/blender/simulations/bparticles/node_frontend.cpp

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

diff --git a/source/blender/blenlib/BLI_lazy_init_cxx.h b/source/blender/blenlib/BLI_lazy_init_cxx.h
index 984e29cc1cb..c6180a22f68 100644
--- a/source/blender/blenlib/BLI_lazy_init_cxx.h
+++ b/source/blender/blenlib/BLI_lazy_init_cxx.h
@@ -58,7 +58,3 @@ void lazy_init_register(std::function<void()> free_func, const char *name);
     return value; \
   } \
   type func_name##_impl(void)
-
-#define BLI_LAZY_INIT_STATIC(type, func_name) \
-  static type &func_name(void); \
-  BLI_LAZY_INIT(type, func_name)
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index 59c1b057858..8e5ddc553fb 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -1044,9 +1044,9 @@ static void PARSE_always_execute(FNodeInfluencesBuilder &builder)
   builder.add_offset_handler(system_names, offset_handler);
 }
 
-BLI_LAZY_INIT_STATIC(StringMap<ParseNodeCallback>, get_node_parsers)
+static StringMap<ParseNodeCallback, BLI::RawAllocator> create_node_parsers_map()
 {
-  StringMap<ParseNodeCallback> map;
+  StringMap<ParseNodeCallback, BLI::RawAllocator> map;
   map.add_new("fn_PointEmitterNode", PARSE_point_emitter);
   map.add_new("fn_CustomEmitterNode", PARSE_custom_emitter);
   map.add_new("fn_MeshEmitterNode", PARSE_mesh_emitter);
@@ -1061,6 +1061,9 @@ BLI_LAZY_INIT_STATIC(StringMap<ParseNodeCallback>, get_node_parsers)
   return map;
 }
 
+static StringMap<ParseNodeCallback, BLI::RawAllocator> node_parsers_map =
+    create_node_parsers_map();
+
 static void collect_influences(FunctionTreeData &function_tree_data,
                                WorldTransition &world_transition,
                                Vector<std::string> &r_system_names,
@@ -1069,8 +1072,6 @@ static void collect_influences(FunctionTreeData &function_tree_data,
 {
   SCOPED_TIMER(__func__);
 
-  StringMap<ParseNodeCallback> &parsers = get_node_parsers();
-
   for (const FNode *fnode :
        function_tree_data.function_tree().nodes_with_idname(particle_system_idname)) {
     StringRef name = fnode->name();
@@ -1091,7 +1092,7 @@ static void collect_influences(FunctionTreeData &function_tree_data,
 
   for (const FNode *fnode : function_tree_data.function_tree().all_nodes()) {
     StringRef idname = fnode->idname();
-    ParseNodeCallback *callback = parsers.lookup_ptr(idname);
+    ParseNodeCallback *callback = node_parsers_map.lookup_ptr(idname);
     if (callback != nullptr) {
       FNodeInfluencesBuilder builder{collector, function_tree_data, world_transition, *fnode};
       (*callback)(builder);



More information about the Bf-blender-cvs mailing list