[gcc r15-1166] libstdc++: [_Hashtable] Optimize destructor

Francois Dumont fdumont@gcc.gnu.org
Mon Jun 10 16:58:15 GMT 2024


https://gcc.gnu.org/g:6ef888177251653fd89b9f127d707bdad04eecbe

commit r15-1166-g6ef888177251653fd89b9f127d707bdad04eecbe
Author: François Dumont <fdumont@gcc.gnu.org>
Date:   Thu Apr 25 18:45:59 2024 +0200

    libstdc++: [_Hashtable] Optimize destructor
    
    Hashtable destructor do not need to call clear() method that in addition to
    destroying all nodes also reset all buckets to nullptr.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/hashtable.h (~_Hashtable()): Replace clear call with
            a _M_deallocate_nodes call.

Diff:
---
 libstdc++-v3/include/bits/hashtable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h
index cd3e1ac297c..6e78cb7d9c0 100644
--- a/libstdc++-v3/include/bits/hashtable.h
+++ b/libstdc++-v3/include/bits/hashtable.h
@@ -1664,7 +1664,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		    "Cache the hash code or qualify your functors involved"
 		    " in hash code and bucket index computation with noexcept");
 
-      clear();
+      this->_M_deallocate_nodes(_M_begin());
       _M_deallocate_buckets();
     }


More information about the Gcc-cvs mailing list