Skip to content

Commit

Permalink
Avoid some string copies
Browse files Browse the repository at this point in the history
Summary: This is a behavior-preserving change.

Reviewed By: wsanville

Differential Revision: D49210587

fbshipit-source-id: 7d1d8ce235feff0d80375635299a51f4db471199
  • Loading branch information
Nikolai Tillmann authored and facebook-github-bot committed Sep 13, 2023
1 parent 429bb39 commit 8a9db6c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libredex/DexClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ std::string get_simple_deobf_name(const T* ref) {
const auto& full_name = ref->get_deobfuscated_name_or_empty();
if (full_name.empty()) {
// This comes up for redex-created methods/fields.
return std::string(ref->c_str());
return ref->str_copy();
}
auto dot_pos = full_name.find('.');
auto colon_pos = full_name.find(':');
Expand Down
4 changes: 2 additions & 2 deletions libredex/RedexContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ void RedexContext::mutate_field(DexFieldRef* field,
if (rename_on_collision && s_field_map.find(r) != s_field_map.end()) {
uint32_t i = 0;
while (true) {
r.name = DexString::make_string(("f$" + std::to_string(i++)).c_str());
r.name = DexString::make_string("f$" + std::to_string(i++));
if (s_field_map.find(r) == s_field_map.end()) {
break;
}
Expand Down Expand Up @@ -680,7 +680,7 @@ void RedexContext::mutate_method(DexMethodRef* method,
prefix = r.name->str() + "$";
}
do {
r.name = DexString::make_string((prefix + std::to_string(i++)).c_str());
r.name = DexString::make_string(prefix + std::to_string(i++));
} while (s_method_map.count(r));
} else {
// We are about to change its class. Use a better name to remember its
Expand Down

0 comments on commit 8a9db6c

Please sign in to comment.