[Bf-blender-cvs] [1e74b276c4e] functions: don't inline grow for other data structures

Jacques Lucke noreply at git.blender.org
Fri Aug 23 17:35:49 CEST 2019


Commit: 1e74b276c4e6ae505b17da3c0eb7b0fc59523f79
Author: Jacques Lucke
Date:   Fri Aug 23 16:57:24 2019 +0200
Branches: functions
https://developer.blender.org/rB1e74b276c4e6ae505b17da3c0eb7b0fc59523f79

don't inline grow for other data structures

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

M	source/blender/blenlib/BLI_string_map.hpp
M	source/blender/blenlib/BLI_vector.hpp

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

diff --git a/source/blender/blenlib/BLI_string_map.hpp b/source/blender/blenlib/BLI_string_map.hpp
index 596e63ca42e..d625de3d16d 100644
--- a/source/blender/blenlib/BLI_string_map.hpp
+++ b/source/blender/blenlib/BLI_string_map.hpp
@@ -342,12 +342,12 @@ template<typename T, typename Allocator = GuardedAllocator> class StringMap {
 
   void ensure_can_add()
   {
-    if (m_array.should_grow()) {
+    if (UNLIKELY(m_array.should_grow())) {
       this->grow(this->size() + 1);
     }
   }
 
-  void grow(uint min_usable_slots)
+  BLI_NOINLINE void grow(uint min_usable_slots)
   {
     ArrayType new_array = m_array.init_reserved(min_usable_slots);
     for (Item &old_item : m_array) {
diff --git a/source/blender/blenlib/BLI_vector.hpp b/source/blender/blenlib/BLI_vector.hpp
index 6cc78ac006b..a6ecfb23cf5 100644
--- a/source/blender/blenlib/BLI_vector.hpp
+++ b/source/blender/blenlib/BLI_vector.hpp
@@ -472,12 +472,12 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class Ve
 
   inline void ensure_space_for_one()
   {
-    if (m_size >= m_capacity) {
+    if (UNLIKELY(m_size >= m_capacity)) {
       this->grow(std::max(m_capacity * 2, (uint)1));
     }
   }
 
-  void grow(uint min_capacity)
+  BLI_NOINLINE void grow(uint min_capacity)
   {
     if (m_capacity >= min_capacity) {
       return;



More information about the Bf-blender-cvs mailing list