Skip to content

Commit a5ffdae

Browse files
RaisinTenruyadorno
authored andcommitted
src: replace push_back with emplace_back in debug_utils
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>
1 parent 4d5273b commit a5ffdae

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/debug_utils.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ std::vector<std::string> NativeSymbolDebuggingContext::GetLoadedLibraries() {
377377
[](struct dl_phdr_info* info, size_t size, void* data) {
378378
auto list = static_cast<std::vector<std::string>*>(data);
379379
if (*info->dlpi_name != '\0') {
380-
list->push_back(info->dlpi_name);
380+
list->emplace_back(info->dlpi_name);
381381
}
382382
return 0;
383383
},
@@ -386,7 +386,7 @@ std::vector<std::string> NativeSymbolDebuggingContext::GetLoadedLibraries() {
386386
uint32_t i = 0;
387387
for (const char* name = _dyld_get_image_name(i); name != nullptr;
388388
name = _dyld_get_image_name(++i)) {
389-
list.push_back(name);
389+
list.emplace_back(name);
390390
}
391391

392392
#elif _AIX
@@ -411,10 +411,10 @@ std::vector<std::string> NativeSymbolDebuggingContext::GetLoadedLibraries() {
411411
strlen(cur_info->ldinfo_filename) + 1;
412412
if (*member_name != '\0') {
413413
str << cur_info->ldinfo_filename << "(" << member_name << ")";
414-
list.push_back(str.str());
414+
list.emplace_back(str.str());
415415
str.str("");
416416
} else {
417-
list.push_back(cur_info->ldinfo_filename);
417+
list.emplace_back(cur_info->ldinfo_filename);
418418
}
419419
buf += cur_info->ldinfo_next;
420420
} while (cur_info->ldinfo_next != 0);
@@ -424,7 +424,7 @@ std::vector<std::string> NativeSymbolDebuggingContext::GetLoadedLibraries() {
424424

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

@@ -459,7 +459,7 @@ std::vector<std::string> NativeSymbolDebuggingContext::GetLoadedLibraries() {
459459
char* str = new char[size];
460460
WideCharToMultiByte(
461461
CP_UTF8, 0, module_name, -1, str, size, nullptr, nullptr);
462-
list.push_back(str);
462+
list.emplace_back(str);
463463
}
464464
}
465465
}

0 commit comments

Comments
 (0)