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:
parent
3ec17a88ba
commit
b2652beceb
19 changed files with 62 additions and 69 deletions
|
@ -28,8 +28,9 @@ void DragFileItems(const std::vector<base::FilePath>& files,
|
|||
*views::Widget::GetTopLevelWidgetForNativeView(view), data.get());
|
||||
|
||||
std::vector<ui::FileInfo> file_infos;
|
||||
file_infos.reserve(files.size());
|
||||
for (const base::FilePath& file : files) {
|
||||
file_infos.push_back(ui::FileInfo(file, base::FilePath()));
|
||||
file_infos.emplace_back(file, base::FilePath());
|
||||
}
|
||||
data->SetFilenames(file_infos);
|
||||
|
||||
|
|
|
@ -229,13 +229,11 @@ void FileChooserDialog::OnFileDialogResponse(GtkWidget* widget, int response) {
|
|||
}
|
||||
|
||||
void FileChooserDialog::AddFilters(const Filters& filters) {
|
||||
for (size_t i = 0; i < filters.size(); ++i) {
|
||||
const Filter& filter = filters[i];
|
||||
for (const auto& filter : filters) {
|
||||
GtkFileFilter* gtk_filter = gtk_file_filter_new();
|
||||
|
||||
for (size_t j = 0; j < filter.second.size(); ++j) {
|
||||
auto file_extension =
|
||||
std::make_unique<std::string>("." + filter.second[j]);
|
||||
for (const auto& extension : filter.second) {
|
||||
auto file_extension = std::make_unique<std::string>("." + extension);
|
||||
gtk_file_filter_add_custom(
|
||||
gtk_filter, GTK_FILE_FILTER_FILENAME,
|
||||
reinterpret_cast<GtkFileFilterFunc>(FileFilterCaseInsensitive),
|
||||
|
|
|
@ -48,16 +48,14 @@ void ConvertFilters(const Filters& filters,
|
|||
}
|
||||
|
||||
buffer->reserve(filters.size() * 2);
|
||||
for (size_t i = 0; i < filters.size(); ++i) {
|
||||
const Filter& filter = filters[i];
|
||||
|
||||
for (const Filter& filter : filters) {
|
||||
COMDLG_FILTERSPEC spec;
|
||||
buffer->push_back(base::UTF8ToWide(filter.first));
|
||||
spec.pszName = buffer->back().c_str();
|
||||
|
||||
std::vector<std::string> extensions(filter.second);
|
||||
for (size_t j = 0; j < extensions.size(); ++j)
|
||||
extensions[j].insert(0, "*.");
|
||||
for (std::string& extension : extensions)
|
||||
extension.insert(0, "*.");
|
||||
buffer->push_back(base::UTF8ToWide(base::JoinString(extensions, ";")));
|
||||
spec.pszSpec = buffer->back().c_str();
|
||||
|
||||
|
|
|
@ -159,9 +159,8 @@ bool MenuBar::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
|||
views::FocusManager::FocusChangeReason::kFocusTraversal);
|
||||
return true;
|
||||
default: {
|
||||
auto children = GetChildrenInZOrder();
|
||||
for (int i = 0, n = children.size(); i < n; ++i) {
|
||||
auto* button = static_cast<SubmenuButton*>(children[i]);
|
||||
for (auto* child : GetChildrenInZOrder()) {
|
||||
auto* button = static_cast<SubmenuButton*>(child);
|
||||
bool shifted = false;
|
||||
auto keycode =
|
||||
electron::KeyboardCodeFromCharCode(button->accelerator(), &shifted);
|
||||
|
@ -204,10 +203,9 @@ bool MenuBar::SetPaneFocus(views::View* initial_focus) {
|
|||
bool result = views::AccessiblePaneView::SetPaneFocus(initial_focus);
|
||||
|
||||
if (result) {
|
||||
auto children = GetChildrenInZOrder();
|
||||
std::set<ui::KeyboardCode> reg;
|
||||
for (int i = 0, n = children.size(); i < n; ++i) {
|
||||
auto* button = static_cast<SubmenuButton*>(children[i]);
|
||||
for (auto* child : GetChildrenInZOrder()) {
|
||||
auto* button = static_cast<SubmenuButton*>(child);
|
||||
bool shifted = false;
|
||||
auto keycode =
|
||||
electron::KeyboardCodeFromCharCode(button->accelerator(), &shifted);
|
||||
|
@ -235,10 +233,9 @@ void MenuBar::RemovePaneFocus() {
|
|||
views::AccessiblePaneView::RemovePaneFocus();
|
||||
SetAcceleratorVisibility(false);
|
||||
|
||||
auto children = GetChildrenInZOrder();
|
||||
std::set<ui::KeyboardCode> unreg;
|
||||
for (int i = 0, n = children.size(); i < n; ++i) {
|
||||
auto* button = static_cast<SubmenuButton*>(children[i]);
|
||||
for (auto* child : GetChildrenInZOrder()) {
|
||||
auto* button = static_cast<SubmenuButton*>(child);
|
||||
bool shifted = false;
|
||||
auto keycode =
|
||||
electron::KeyboardCodeFromCharCode(button->accelerator(), &shifted);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue