This is an automated email from the ASF dual-hosted git repository.

gangwu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new 4133aa2c refactor: use std::ranges::to in ToUpper and ToLower (#382)
4133aa2c is described below

commit 4133aa2c21a2486a100627fef2cbff40774dd806
Author: Junwang Zhao <[email protected]>
AuthorDate: Tue Dec 2 23:56:20 2025 +0800

    refactor: use std::ranges::to in ToUpper and ToLower (#382)
    
    CI moved to gcc-14 and other code already uses std::ranges::to, so the
    TODO can be removed.
---
 src/iceberg/util/string_util.h | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/iceberg/util/string_util.h b/src/iceberg/util/string_util.h
index aafb740c..8eee314f 100644
--- a/src/iceberg/util/string_util.h
+++ b/src/iceberg/util/string_util.h
@@ -30,19 +30,13 @@ namespace iceberg {
 class ICEBERG_EXPORT StringUtils {
  public:
   static std::string ToLower(std::string_view str) {
-    std::string input(str);
-    // TODO(xiao.dong) gcc 13.3 didn't support std::ranges::to
-    std::transform(input.begin(), input.end(), input.begin(),  // NOLINT
-                   [](char c) { return std::tolower(c); });    // NOLINT
-    return input;
+    return str | std::ranges::views::transform([](char c) { return 
std::tolower(c); }) |
+           std::ranges::to<std::string>();
   }
 
   static std::string ToUpper(std::string_view str) {
-    std::string input(str);
-    // TODO(xiao.dong) gcc 13.3 didn't support std::ranges::to
-    std::transform(input.begin(), input.end(), input.begin(),  // NOLINT
-                   [](char c) { return std::toupper(c); });    // NOLINT
-    return input;
+    return str | std::ranges::views::transform([](char c) { return 
std::toupper(c); }) |
+           std::ranges::to<std::string>();
   }
 
   static bool EqualsIgnoreCase(std::string_view lhs, std::string_view rhs) {

Reply via email to