Skip to content

Commit fbcf7a1

Browse files
Copilotnunoplopes
andauthored
refactor: move ReplaceAll definition from header to converter_lib.cpp
Agent-Logs-Url: https://github.com/Cpp2Rust/cpp2rust/sessions/5adfcfd4-fbee-476c-afc9-cb60f688cec2 Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com>
1 parent 29aa19a commit fbcf7a1

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

cpp2rust/converter/converter_lib.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,4 +762,16 @@ void Unwrap(std::string &s, std::string_view prefix, std::string_view suffix) {
762762
}
763763
}
764764

765+
std::string ReplaceAll(std::string str, std::string_view from,
766+
std::string_view to) {
767+
if (from.empty())
768+
return str;
769+
size_t pos = 0;
770+
while ((pos = str.find(from, pos)) != std::string::npos) {
771+
str.replace(pos, from.size(), to);
772+
pos += to.size();
773+
}
774+
return str;
775+
}
776+
765777
} // namespace cpp2rust

cpp2rust/converter/converter_lib.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,7 @@ std::vector<clang::Stmt *> GetSwitchCaseBody(clang::CompoundStmt *body,
166166

167167
void Unwrap(std::string &s, std::string_view prefix, std::string_view suffix);
168168

169-
inline std::string ReplaceAll(std::string str, std::string_view from,
170-
std::string_view to) {
171-
if (from.empty())
172-
return str;
173-
size_t pos = 0;
174-
while ((pos = str.find(from, pos)) != std::string::npos) {
175-
str.replace(pos, from.size(), to);
176-
pos += to.size();
177-
}
178-
return str;
179-
}
169+
std::string ReplaceAll(std::string str, std::string_view from,
170+
std::string_view to);
180171

181172
} // namespace cpp2rust

0 commit comments

Comments
 (0)