[libcxx-commits] [libcxx] 7c932cd - [NFC][libc++][format] Uses ranges algorithm.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 20 09:59:58 PDT 2022


Author: Mark de Wever
Date: 2022-09-20T18:59:50+02:00
New Revision: 7c932cdb10fe6223a929661fae7485bb535f94d8

URL: https://github.com/llvm/llvm-project/commit/7c932cdb10fe6223a929661fae7485bb535f94d8
DIFF: https://github.com/llvm/llvm-project/commit/7c932cdb10fe6223a929661fae7485bb535f94d8.diff

LOG: [NFC][libc++][format] Uses ranges algorithm.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D134060

Added: 
    

Modified: 
    libcxx/include/__format/extended_grapheme_cluster_table.h
    libcxx/utils/generate_extended_grapheme_cluster_table.py

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__format/extended_grapheme_cluster_table.h b/libcxx/include/__format/extended_grapheme_cluster_table.h
index 69d30438e3029..d16d8422f4696 100644
--- a/libcxx/include/__format/extended_grapheme_cluster_table.h
+++ b/libcxx/include/__format/extended_grapheme_cluster_table.h
@@ -61,7 +61,7 @@
 #ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
 #define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
 
-#include <__algorithm/upper_bound.h>
+#include <__algorithm/ranges_upper_bound.h>
 #include <__config>
 #include <__iterator/access.h>
 #include <cstddef>
@@ -1608,8 +1608,6 @@ inline constexpr uint32_t __entries[1480] = {
 
 /// Returns the extended grapheme cluster bondary property of a code point.
 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {
-  // TODO FMT use std::ranges::upper_bound.
-
   // The algorithm searches for the upper bound of the range and, when found,
   // steps back one entry. This algorithm is used since the code point can be
   // anywhere in the range. After a lower bound is found the next step is to
@@ -1626,7 +1624,7 @@ inline constexpr uint32_t __entries[1480] = {
   // size. Then the upper bound for code point 3 will return the entry after
   // 0x1810. After moving to the previous entry the algorithm arrives at the
   // correct entry.
-  ptr
diff _t __i = std::upper_bound(__entries, std::end(__entries), (__code_point << 11) | 0x7ffu) - __entries;
+  ptr
diff _t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries;
   if (__i == 0)
     return __property::__none;
 

diff  --git a/libcxx/utils/generate_extended_grapheme_cluster_table.py b/libcxx/utils/generate_extended_grapheme_cluster_table.py
index f508d469939c5..7dd201615ee03 100755
--- a/libcxx/utils/generate_extended_grapheme_cluster_table.py
+++ b/libcxx/utils/generate_extended_grapheme_cluster_table.py
@@ -117,8 +117,6 @@ def compactPropertyRanges(input: list[PropertyRange]) -> list[PropertyRange]:
 
 /// Returns the extended grapheme cluster bondary property of a code point.
 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {{
-  // TODO FMT use std::ranges::upper_bound.
-
   // The algorithm searches for the upper bound of the range and, when found,
   // steps back one entry. This algorithm is used since the code point can be
   // anywhere in the range. After a lower bound is found the next step is to
@@ -135,7 +133,7 @@ def compactPropertyRanges(input: list[PropertyRange]) -> list[PropertyRange]:
   // size. Then the upper bound for code point 3 will return the entry after
   // 0x1810. After moving to the previous entry the algorithm arrives at the
   // correct entry.
-  ptr
diff _t __i = std::upper_bound(__entries, std::end(__entries), (__code_point << 11) | 0x7ffu) - __entries;
+  ptr
diff _t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries;
   if (__i == 0)
     return __property::__none;
 
@@ -212,7 +210,7 @@ def compactPropertyRanges(input: list[PropertyRange]) -> list[PropertyRange]:
 #ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
 #define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
 
-#include <__algorithm/upper_bound.h>
+#include <__algorithm/ranges_upper_bound.h>
 #include <__config>
 #include <__iterator/access.h>
 #include <cstddef>


        


More information about the libcxx-commits mailing list