[PATCH] D52697: Bug 39129: Speeding up partition_point/lower_bound/upper_bound/ by using unsigned division by 2 when possible.

Eric Fiselier via Phabricator reviews at reviews.llvm.org
Sat Oct 13 13:48:25 PDT 2018


EricWF added inline comments.


================
Comment at: include/algorithm:754
+// Perform division by two quickly for positive integers (llvm.org/PR39129)
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 ptrdiff_t
+__half_positive(ptrdiff_t __value)
----------------
I think we can use `_LIBCPP_CONSTEXPR` here and get better behavior in C++03. 


================
Comment at: include/algorithm:760
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp
----------------
While this version is certainly simplier,  I would still like to have this work for all of the builtin signed integral types. 



================
Comment at: test/libcxx/algorithms/half_positive.pass.cpp:27
+int main()
+{
+    {
----------------
Please make sure this test compiles in C++03, C++11, ect. 

You'll want to use `TEST_STD_VER` from `test_macros.h` to guard the constexpr tests.


https://reviews.llvm.org/D52697





More information about the libcxx-commits mailing list