Optimize SortedArrayMap by using linear search for small arrays
Created attachment 427396 [details] Patch
Comment on attachment 427396 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=427396&action=review r=me > Source/WTF/wtf/SortedArrayMap.h:145 > + if (std::size(m_array) < binarySearchThreshold) { How about making it `if constexpr` to ensure that this dispatching is done at compile time. > Source/WTF/wtf/SortedArrayMap.h:177 > + if (std::size(m_array) < binarySearchThreshold) Ditto.
Comment on attachment 427396 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=427396&action=review >> Source/WTF/wtf/SortedArrayMap.h:145 >> + if (std::size(m_array) < binarySearchThreshold) { > > How about making it `if constexpr` to ensure that this dispatching is done at compile time. Tried if constexpr first. The compiler gave an error saying that I could not use "this" in it, so I would have had to find some way to get the size from the type rather than from m_array. Decided to leave it non-constexpr; still gets constant-folded.
Comment on attachment 427396 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=427396&action=review >>> Source/WTF/wtf/SortedArrayMap.h:145 >>> + if (std::size(m_array) < binarySearchThreshold) { >> >> How about making it `if constexpr` to ensure that this dispatching is done at compile time. > > Tried if constexpr first. The compiler gave an error saying that I could not use "this" in it, so I would have had to find some way to get the size from the type rather than from m_array. Decided to leave it non-constexpr; still gets constant-folded. If you help me find a clean simple way for me to move to if constexpr without making the code ugly, would be happy to come back and do that later.
Committed r276840 (237191@main): <https://commits.webkit.org/237191@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 427396 [details].
<rdar://problem/77385092>