src: replace push_back with emplace_back in debug_utils

This prevents potential temporary object constructions.

PR-URL: https://github.com/nodejs/node/pull/36897
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
raisinten authored and Ruy Adorno committed 2021-01-24 21:43:35 -05:00
1 parent 4d5273b156
commit a5ffdaee1c
1 file changed
+6 -6
+6 -6
View File
@@ -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;
},
@@ -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
@@ -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);
@@ -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);
}
}
@@ -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);
}
}
}