From 4ae31351eab3497d686b3e6680afa1be52b4f3a7 Mon Sep 17 00:00:00 2001 From: raisinten Date: Tue, 12 Jan 2021 21:10:01 +0530 Subject: [PATCH] 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 Reviewed-By: Antoine du Hamel --- src/debug_utils.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/debug_utils.cc b/src/debug_utils.cc index a601c5ecf40ea9..aa97bfbe943bab 100644 --- a/src/debug_utils.cc +++ b/src/debug_utils.cc @@ -377,7 +377,7 @@ std::vector NativeSymbolDebuggingContext::GetLoadedLibraries() { [](struct dl_phdr_info* info, size_t size, void* data) { auto list = static_cast*>(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 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 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 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 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); } } }