[Bf-blender-cvs] [c1c17ba5425] functions: lookup_default

Jacques Lucke noreply at git.blender.org
Wed Feb 20 17:21:10 CET 2019


Commit: c1c17ba54251e8082774b8f724c615cc12aba325
Author: Jacques Lucke
Date:   Wed Feb 20 12:49:44 2019 +0100
Branches: functions
https://developer.blender.org/rBc1c17ba54251e8082774b8f724c615cc12aba325

lookup_default

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

M	source/blender/blenlib/BLI_small_map.hpp

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

diff --git a/source/blender/blenlib/BLI_small_map.hpp b/source/blender/blenlib/BLI_small_map.hpp
index f57b8ed3ba3..cddf82edd26 100644
--- a/source/blender/blenlib/BLI_small_map.hpp
+++ b/source/blender/blenlib/BLI_small_map.hpp
@@ -44,6 +44,16 @@ namespace BLI {
 			return this->lookup_ref(key);
 		}
 
+		V lookup_default(const K &key, V default_value) const
+		{
+			if (this->contains(key)) {
+				return this->lookup(key);
+			}
+			else {
+				return default_value;
+			}
+		}
+
 		V &lookup_ref(const K &key) const
 		{
 			V *ptr = this->lookup_ptr(key);



More information about the Bf-blender-cvs mailing list