[libcxx-commits] [libcxx] [libc++] Optimize string operator[] for known large inputs (PR #69500)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 19 18:21:54 PDT 2023


================
@@ -1198,11 +1198,17 @@ public:
 
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __pos) const _NOEXCEPT {
     _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__pos <= size(), "string index out of bounds");
+    if (__builtin_constant_p(__pos) && !__fits_in_sso(__pos)) {
----------------
ldionne wrote:

Okay, I think I'm leaning towards wanting this.

https://github.com/llvm/llvm-project/pull/69500


More information about the libcxx-commits mailing list