[Bf-blender-cvs] [80ce0cd20f8] functions: join map.lookup and map.lookup_ref
Jacques Lucke
noreply at git.blender.org
Mon Aug 5 13:07:44 CEST 2019
Commit: 80ce0cd20f879d9b59e91a432d0a28d13eeea7e3
Author: Jacques Lucke
Date: Mon Aug 5 12:10:00 2019 +0200
Branches: functions
https://developer.blender.org/rB80ce0cd20f879d9b59e91a432d0a28d13eeea7e3
join map.lookup and map.lookup_ref
===================================================================
M source/blender/blenlib/BLI_map.hpp
M source/blender/blenlib/BLI_string_map.hpp
M source/blender/functions/frontends/data_flow_nodes/mappings.cpp
M source/blender/functions/frontends/data_flow_nodes/mappings.hpp
M source/blender/functions/functions/lists.cpp
M source/blender/functions/functions/switch.cpp
M source/blender/simulations/bparticles/node_frontend.cpp
===================================================================
diff --git a/source/blender/blenlib/BLI_map.hpp b/source/blender/blenlib/BLI_map.hpp
index 916bf955dd8..c24f694ddbe 100644
--- a/source/blender/blenlib/BLI_map.hpp
+++ b/source/blender/blenlib/BLI_map.hpp
@@ -126,9 +126,11 @@ template<typename K, typename V, uint N = 4> class Map {
* Return the value corresponding to the key.
* This will assert when the key does not exist.
*/
- V lookup(const K &key) const
+ V &lookup(const K &key) const
{
- return this->lookup_ref(key);
+ V *ptr = this->lookup_ptr(key);
+ BLI_assert(ptr);
+ return *ptr;
}
/**
@@ -146,17 +148,6 @@ template<typename K, typename V, uint N = 4> class Map {
}
}
- /**
- * Return a reference to the value corresponding to a key.
- * This will assert when the key does not exist.
- */
- V &lookup_ref(const K &key) const
- {
- V *ptr = this->lookup_ptr(key);
- BLI_assert(ptr);
- return *ptr;
- }
-
/**
* Return a pointer to the value corresponding to the key.
* Returns nullptr when the key does not exist.
diff --git a/source/blender/blenlib/BLI_string_map.hpp b/source/blender/blenlib/BLI_string_map.hpp
index 457f335ad89..ded285e434d 100644
--- a/source/blender/blenlib/BLI_string_map.hpp
+++ b/source/blender/blenlib/BLI_string_map.hpp
@@ -53,7 +53,7 @@ template<typename V> class StringMap {
m_map.add_override(key.to_std_string(), value);
}
- V lookup(StringRef key) const
+ V &lookup(StringRef key) const
{
return m_map.lookup(key.to_std_string());
}
@@ -68,11 +68,6 @@ template<typename V> class StringMap {
return m_map.lookup_default(key.to_std_string(), default_value);
}
- V &lookup_ref(StringRef key) const
- {
- return m_map.lookup_ref(key.to_std_string());
- }
-
bool contains(StringRef key) const
{
return m_map.contains(key.to_std_string());
diff --git a/source/blender/functions/frontends/data_flow_nodes/mappings.cpp b/source/blender/functions/frontends/data_flow_nodes/mappings.cpp
index fb9a3ea2b23..4b8710e15c5 100644
--- a/source/blender/functions/frontends/data_flow_nodes/mappings.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/mappings.cpp
@@ -79,7 +79,7 @@ void SocketLoaders::register_loader(StringRef type_name, SocketLoader loader)
void SocketLoaders::load(VirtualSocket *vsocket, Tuple &dst, uint index)
{
- SocketLoader &loader = m_loader_by_idname.lookup_ref(vsocket->idname());
+ SocketLoader &loader = m_loader_by_idname.lookup(vsocket->idname());
PointerRNA rna = vsocket->rna();
loader(&rna, dst, index);
}
diff --git a/source/blender/functions/frontends/data_flow_nodes/mappings.hpp b/source/blender/functions/frontends/data_flow_nodes/mappings.hpp
index 3798432a95a..d5d509760c0 100644
--- a/source/blender/functions/frontends/data_flow_nodes/mappings.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/mappings.hpp
@@ -42,22 +42,22 @@ class TypeMappings {
SharedType &type_by_idname(StringRef idname)
{
- return m_type_by_idname.lookup_ref(idname);
+ return m_type_by_idname.lookup(idname);
}
SharedType &type_by_name(StringRef name)
{
- return m_type_by_name.lookup_ref(name);
+ return m_type_by_name.lookup(name);
}
StringRefNull name_by_idname(StringRef idname)
{
- return m_name_by_idname.lookup_ref(idname);
+ return m_name_by_idname.lookup(idname);
}
StringRefNull idname_by_name(StringRef name)
{
- return m_idname_by_name.lookup_ref(name);
+ return m_idname_by_name.lookup(name);
}
};
diff --git a/source/blender/functions/functions/lists.cpp b/source/blender/functions/functions/lists.cpp
index cd6ac1ec82a..d3284f122b8 100644
--- a/source/blender/functions/functions/lists.cpp
+++ b/source/blender/functions/functions/lists.cpp
@@ -283,42 +283,42 @@ SharedFunction &GET_FN_empty_list(SharedType &base_type)
{
FunctionPerType &functions = get_list_functions().m_create_empty;
BLI_assert(functions.contains(base_type));
- return functions.lookup_ref(base_type);
+ return functions.lookup(base_type);
}
SharedFunction &GET_FN_list_from_element(SharedType &base_type)
{
FunctionPerType &functions = get_list_functions().m_from_element;
BLI_assert(functions.contains(base_type));
- return functions.lookup_ref(base_type);
+ return functions.lookup(base_type);
}
SharedFunction &GET_FN_append_to_list(SharedType &base_type)
{
FunctionPerType &functions = get_list_functions().m_append;
BLI_assert(functions.contains(base_type));
- return functions.lookup_ref(base_type);
+ return functions.lookup(base_type);
}
SharedFunction &GET_FN_get_list_element(SharedType &base_type)
{
FunctionPerType &functions = get_list_functions().m_get_element;
BLI_assert(functions.contains(base_type));
- return functions.lookup_ref(base_type);
+ return functions.lookup(base_type);
}
SharedFunction &GET_FN_combine_lists(SharedType &base_type)
{
FunctionPerType &functions = get_list_functions().m_combine;
BLI_assert(functions.contains(base_type));
- return functions.lookup_ref(base_type);
+ return functions.lookup(base_type);
}
SharedFunction &GET_FN_list_length(SharedType &base_type)
{
FunctionPerType &functions = get_list_functions().m_length;
BLI_assert(functions.contains(base_type));
- return functions.lookup_ref(base_type);
+ return functions.lookup(base_type);
}
SharedType &get_list_type(SharedType &base_type)
diff --git a/source/blender/functions/functions/switch.cpp b/source/blender/functions/functions/switch.cpp
index 250bece4bd1..df262403caa 100644
--- a/source/blender/functions/functions/switch.cpp
+++ b/source/blender/functions/functions/switch.cpp
@@ -83,7 +83,7 @@ SharedFunction &GET_FN_bool_switch(SharedType &data_type)
SharedFunction fn = build_bool_switch_function(data_type);
cache.add(data_type, fn);
}
- return cache.lookup_ref(data_type);
+ return cache.lookup(data_type);
}
} // namespace Functions
diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp
index dca665621e2..ba4cf6882ff 100644
--- a/source/blender/simulations/bparticles/node_frontend.cpp
+++ b/source/blender/simulations/bparticles/node_frontend.cpp
@@ -150,7 +150,7 @@ std::unique_ptr<StepDescription> step_description_from_node_tree(VirtualNodeTree
integrator = new EulerIntegrator(forces_on_type);
}
- ParticleType *particle_type = new ParticleType(declarations.lookup_ref(name),
+ ParticleType *particle_type = new ParticleType(declarations.lookup(name),
integrator,
events.lookup_default(name),
offset_handlers.lookup_default(name));
More information about the Bf-blender-cvs
mailing list