From 7c932cdb10fe6223a929661fae7485bb535f94d8 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Fri, 16 Sep 2022 20:47:01 +0200 Subject: [PATCH] [NFC][libc++][format] Uses ranges algorithm. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D134060 --- libcxx/include/__format/extended_grapheme_cluster_table.h | 6 ++---- libcxx/utils/generate_extended_grapheme_cluster_table.py | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/libcxx/include/__format/extended_grapheme_cluster_table.h b/libcxx/include/__format/extended_grapheme_cluster_table.h index 69d3043..d16d842 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 @@ -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. - ptrdiff_t __i = std::upper_bound(__entries, std::end(__entries), (__code_point << 11) | 0x7ffu) - __entries; + ptrdiff_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 f508d46..7dd2016 100755 --- a/libcxx/utils/generate_extended_grapheme_cluster_table.py +++ b/libcxx/utils/generate_extended_grapheme_cluster_table.py @@ -117,8 +117,6 @@ inline constexpr uint32_t __entries[{size}] = {{ /// 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 @@ inline constexpr uint32_t __entries[{size}] = {{ // 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. - ptrdiff_t __i = std::upper_bound(__entries, std::end(__entries), (__code_point << 11) | 0x7ffu) - __entries; + ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries; if (__i == 0) return __property::__none; @@ -212,7 +210,7 @@ MSVC_FORMAT_UCD_TABLES_HPP_TEMPLATE = """ #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 -- 2.7.4