[libcxx-commits] [libcxx] [libc++] Optimize lexicographical_compare (PR #65279)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jul 28 05:13:13 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff fe07d9aa410518c5b631a065ddc5782a623af030 86967cb50c7533fd34a6cc074b7ec523035e2226 --extensions cpp,h -- libcxx/benchmarks/algorithms/lexicographical_compare.bench.cpp libcxx/include/__algorithm/comp.h libcxx/include/__algorithm/lexicographical_compare.h libcxx/include/__algorithm/ranges_lexicographical_compare.h libcxx/include/__algorithm/ranges_minmax.h libcxx/include/__functional/operations.h libcxx/include/__functional/ranges_operations.h libcxx/include/__string/constexpr_c_functions.h libcxx/include/__type_traits/desugars_to.h libcxx/include/__type_traits/is_trivially_lexicographically_comparable.h libcxx/test/std/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/__algorithm/lexicographical_compare.h b/libcxx/include/__algorithm/lexicographical_compare.h
index db689e427b..97152a7bc6 100644
--- a/libcxx/include/__algorithm/lexicographical_compare.h
+++ b/libcxx/include/__algorithm/lexicographical_compare.h
@@ -70,14 +70,14 @@ __lexicographical_compare(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __las
       return __last1 - __first1 < __last2 - __first2;
     return __res < 0;
   }
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#  ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
   else if constexpr (is_same<__remove_cv_t<_Tp>, wchar_t>::value) {
     auto __res = std::__constexpr_wmemcmp(__first1, __first2, std::min(__last1 - __first1, __last2 - __first2));
     if (__res == 0)
       return __last1 - __first1 < __last2 - __first2;
     return __res < 0;
   }
-#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#  endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
   else {
     auto __res = std::mismatch(__first1, __last1, __first2, __last2);
     if (__res.second == __last2)

``````````

</details>


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


More information about the libcxx-commits mailing list