🌘 「noexcept」影響libstdc++的unordered_set - Arthur O'Dwyer - 主要關於C++的東西
➤ 哈希式關聯容器中的noexcept對性能的影響
https://quuxplusone.github.io/blog/2024/08/16/libstdcxx-noexcept-hash/
在GNU libstdc++的哈希式關聯容器中,添加或刪除noexcept可能會改變程序的性能。在C++中,std::unordered_set基本上是一個“桶”的向量,其中每個桶是一個“節點”的鏈表,每個節點存儲unordered_set的一個元素。根據哈希函數的noexcept性質,這些容器將其節點的結構佈局進行更改。
+ 這是一個很有趣的發現,對於使用libstdc++的開發者來說是一個重要的提示。
+ 我以前從未注意到這個細節,謝謝作者的分享。
#C++ #libstdc++ #unordered_set #哈希函數
noexcept affects libstdc++’s unordered_set

The other day I learned a new place where adding or removing noexcept can change the performance of your program: GNU libstdc++’s hash-based associative containers change the struct layout of their nodes depending on the noexceptness of your hash function. This is laid out fairly clearly in the docs; it’s simply bizarre enough that I’d never thought to look for such a thing in the docs!

Arthur O’Dwyer