Skip to content

Commit a3f4805

Browse files
Copilotnunoplopes
andauthored
Fix comment and remove unreachable char overload per code review
- Fix inaccurate comment: non-literal args use two appends (+= val, += ' '), not one concatenated append as the old comment implied. - Remove the char-specific _AppendRuns overload: all token/keyword constants in lex.h are const char* (not char), so no call site ever passes a bare char argument; the overload was dead code. Agent-Logs-Url: https://github.com/Cpp2Rust/cpp2rust/sessions/baf4f5f7-8950-4369-a9c9-708aaed9ad22 Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com>
1 parent 0dca7ae commit a3f4805

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

cpp2rust/converter/converter.h

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
319319
// appended individually.
320320
// e.g. StrCat("foo", "bar", var1, "xyz") performs:
321321
// rs_code_ += "foo bar " (one append for the merged literal run)
322-
// rs_code_ += var1 + ' ' (one append for the non-literal)
322+
// rs_code_ += val; rs_code_ += ' '; (two appends for the non-literal)
323323
// rs_code_ += "xyz " (one append for the trailing literal)
324324
//
325325
// All _AppendRuns overloads are marked [[gnu::always_inline]] so that Clang
@@ -364,9 +364,9 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
364364
_AppendRuns(rs_code, _ExtendBuf(buf, val), rest...);
365365
}
366366

367-
// Head is NOT a string literal: flush the pending buffer (if any), append
368-
// the non-literal argument (value + space), then continue with an empty
369-
// buffer.
367+
// Head is NOT a string literal: flush the pending buffer (if any), then
368+
// append the non-literal argument followed by a space (two separate appends),
369+
// and continue with an empty buffer.
370370
template <std::size_t BufSize, typename T, typename... Rest>
371371
[[gnu::always_inline]] static void
372372
_AppendRuns(std::string &rs_code, std::array<char, BufSize> buf,
@@ -378,19 +378,6 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
378378
_AppendRuns(rs_code, std::array<char, 0>{}, rest...);
379379
}
380380

381-
// Head is a single char: flush the pending buffer (if any), then append
382-
// the char and its trailing space together as a single 2-byte append.
383-
template <std::size_t BufSize, typename... Rest>
384-
[[gnu::always_inline]] static void
385-
_AppendRuns(std::string &rs_code, std::array<char, BufSize> buf, char val,
386-
const Rest &...rest) {
387-
if constexpr (BufSize > 0)
388-
rs_code.append(buf.data(), BufSize);
389-
const char pair[2] = {val, ' '};
390-
rs_code.append(pair, 2);
391-
_AppendRuns(rs_code, std::array<char, 0>{}, rest...);
392-
}
393-
394381
class Buffer {
395382
std::string partial_code;
396383
std::string *full_code;

0 commit comments

Comments
 (0)