refactor: apply some 'clang-tidy -fix' changes (#20172)

* refactor: fix clang-tidy vector operation warnings

Fix vector population performance-inefficient-vector-operation warnings
generated by clang-tidy

* refactor: fix clang-tidy emplace_back warnings

In cases where a temporary is created to be passed
to push_back(), replace it with emplace_back().

Warning: modernize-use-emplace

* refactor: fix clang-tidy loop iteration warnings

When practical, use range-based for loops instead of C-style for loops.

clang-tiny check: modernize-loop-convert

* refactor: fix clang-tidy string initialize warning

Remove redundant empty string initialization.

clang-tidy check: readability-redundant-string-init
This commit is contained in:
Charles Kerr 2019-09-13 10:26:59 -04:00 committed by GitHub
parent 3ec17a88ba
commit b2652beceb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 62 additions and 69 deletions

View file

@ -93,8 +93,7 @@ CrashReporter::GetUploadedReports(const base::FilePath& crashes_dir) {
int report_time = 0;
if (report_item.size() >= 2 &&
base::StringToInt(report_item[0], &report_time)) {
result.push_back(
CrashReporter::UploadReportResult(report_time, report_item[1]));
result.emplace_back(report_time, report_item[1]);
}
}
}

View file

@ -66,6 +66,7 @@ v8::Local<v8::Value> MenuToV8(v8::Isolate* isolate,
const content::CustomContextMenuContext& context,
const std::vector<content::MenuItem>& menu) {
std::vector<v8::Local<v8::Value>> v8_menu;
v8_menu.reserve(menu.size());
for (const auto& menu_item : menu)
v8_menu.push_back(MenuItemToV8(isolate, web_contents, context, menu_item));
return mate::ConvertToV8(isolate, v8_menu);