[libcxx-commits] [libcxx] a6ce0d0 - [NFC][libc++][format] Use ranges in the output.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 29 09:13:40 PDT 2022


Author: Mark de Wever
Date: 2022-08-29T18:13:30+02:00
New Revision: a6ce0d087a82ef1e2543bf8ada8f37e4a34c610f

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

LOG: [NFC][libc++][format] Use ranges in the output.

This should avoid some copies of the output iterator.

Reviewed By: #libc, Mordante

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

Added: 
    

Modified: 
    libcxx/include/__format/formatter_output.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__format/formatter_output.h b/libcxx/include/__format/formatter_output.h
index 1852c88ea4fb2..8a6ce5ca5fa0f 100644
--- a/libcxx/include/__format/formatter_output.h
+++ b/libcxx/include/__format/formatter_output.h
@@ -10,10 +10,9 @@
 #ifndef _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
 #define _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
 
-#include <__algorithm/copy.h>
-#include <__algorithm/copy_n.h>
-#include <__algorithm/fill_n.h>
-#include <__algorithm/transform.h>
+#include <__algorithm/ranges_copy.h>
+#include <__algorithm/ranges_fill_n.h>
+#include <__algorithm/ranges_transform.h>
 #include <__concepts/same_as.h>
 #include <__config>
 #include <__format/buffer.h>
@@ -99,7 +98,7 @@ _LIBCPP_HIDE_FROM_ABI auto __copy(basic_string_view<_CharT> __str, output_iterat
     __out_it.__get_container()->__copy(__str);
     return __out_it;
   } else {
-    return std::copy_n(__str.data(), __str.size(), _VSTD::move(__out_it));
+    return std::ranges::copy(__str, _VSTD::move(__out_it)).out;
   }
 }
 
@@ -129,7 +128,7 @@ __transform(const _CharT* __first,
     __out_it.__get_container()->__transform(__first, __last, _VSTD::move(__operation));
     return __out_it;
   } else {
-    return std::transform(__first, __last, _VSTD::move(__out_it), __operation);
+    return std::ranges::transform(__first, __last, _VSTD::move(__out_it), __operation).out;
   }
 }
 
@@ -142,7 +141,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, _CharT __value)
     __out_it.__get_container()->__fill(__n, __value);
     return __out_it;
   } else {
-    return std::fill_n(_VSTD::move(__out_it), __n, __value);
+    return std::ranges::fill_n(_VSTD::move(__out_it), __n, __value);
   }
 }
 


        


More information about the libcxx-commits mailing list