Skip to content

Commit 0b3ebce

Browse files
Copilotnunoplopes
andauthored
Use std::copy/std::copy_n in literal-accumulator overload of _AppendRuns
Agent-Logs-Url: https://github.com/Cpp2Rust/cpp2rust/sessions/c9bd1adc-01f6-415e-a50c-9e8a4cb1e414 Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com>
1 parent 6bc7f33 commit 0b3ebce

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

cpp2rust/converter/converter.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <clang/AST/RecursiveASTVisitor.h>
88
#include <clang/Sema/Sema.h>
99

10+
#include <algorithm>
1011
#include <array>
1112
#include <functional>
1213
#include <optional>
@@ -340,10 +341,8 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
340341
static void _AppendRuns(std::string &rs_code, std::array<char, BufSize> buf,
341342
const char (&val)[N], const Rest &...rest) {
342343
std::array<char, BufSize + N> new_buf;
343-
for (std::size_t i = 0; i < BufSize; ++i)
344-
new_buf[i] = buf[i];
345-
for (std::size_t i = 0; i < N - 1; ++i)
346-
new_buf[BufSize + i] = val[i];
344+
std::copy(buf.begin(), buf.end(), new_buf.begin());
345+
std::copy_n(val, N - 1, new_buf.begin() + BufSize);
347346
new_buf[BufSize + N - 1] = ' ';
348347
_AppendRuns(rs_code, new_buf, rest...);
349348
}

0 commit comments

Comments
 (0)