[libcxx-commits] [PATCH] D132812: [NFC][libc++][format] Use ranges in the output.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 29 08:55:32 PDT 2022
Mordante created this revision.
Herald added a project: All.
Mordante published this revision for review.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
This should avoid some copies of the output iterator.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D132812
Files:
libcxx/include/__format/formatter_output.h
Index: libcxx/include/__format/formatter_output.h
===================================================================
--- libcxx/include/__format/formatter_output.h
+++ 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 @@
__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 @@
__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 @@
__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);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132812.456206.patch
Type: text/x-patch
Size: 1490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220829/aa53b74f/attachment.bin>
More information about the libcxx-commits
mailing list