Skip to content

Commit

Permalink
src: replace push_back with emplace_back in debug_utils
Browse files Browse the repository at this point in the history
This prevents potential temporary object constructions.

PR-URL: #36897
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
RaisinTen authored and ruyadorno committed Jan 21, 2021
1 parent 01c24aa commit 9254791
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/debug_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ std::vector<std::string> NativeSymbolDebuggingContext::GetLoadedLibraries() {
[](struct dl_phdr_info* info, size_t size, void* data) {
auto list = static_cast<std::vector<std::string>*>(data);
if (*info->dlpi_name != '\0') {
list->push_back(info->dlpi_name);
list->emplace_back(info->dlpi_name);
}
return 0;
},
Expand All @@ -386,7 +386,7 @@ std::vector<std::string> NativeSymbolDebuggingContext::GetLoadedLibraries() {
uint32_t i = 0;
for (const char* name = _dyld_get_image_name(i); name != nullptr;
name = _dyld_get_image_name(++i)) {
list.push_back(name);
list.emplace_back(name);
}

#elif _AIX
Expand All @@ -411,10 +411,10 @@ std::vector<std::string> NativeSymbolDebuggingContext::GetLoadedLibraries() {
strlen(cur_info->ldinfo_filename) + 1;
if (*member_name != '\0') {
str << cur_info->ldinfo_filename << "(" << member_name << ")";
list.push_back(str.str());
list.emplace_back(str.str());
str.str("");
} else {
list.push_back(cur_info->ldinfo_filename);
list.emplace_back(cur_info->ldinfo_filename);
}
buf += cur_info->ldinfo_next;
} while (cur_info->ldinfo_next != 0);
Expand All @@ -424,7 +424,7 @@ std::vector<std::string> NativeSymbolDebuggingContext::GetLoadedLibraries() {

if (dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &p) != -1) {
for (Link_map* l = p; l != nullptr; l = l->l_next) {
list.push_back(l->l_name);
list.emplace_back(l->l_name);
}
}

Expand Down Expand Up @@ -459,7 +459,7 @@ std::vector<std::string> NativeSymbolDebuggingContext::GetLoadedLibraries() {
char* str = new char[size];
WideCharToMultiByte(
CP_UTF8, 0, module_name, -1, str, size, nullptr, nullptr);
list.push_back(str);
list.emplace_back(str);
}
}
}
Expand Down

0 comments on commit 9254791

Please sign in to comment.