Merge pull request #13090 from mitaclaw/ranges-modernization-1-trivial

Ranges Algorithms Modernization - Trivial
This commit is contained in:
JosJuice
2024-10-15 17:08:55 +02:00
committed by GitHub
52 changed files with 106 additions and 118 deletions

View File

@ -914,7 +914,7 @@ CalibrationWidget::CalibrationWidget(ControllerEmu::ReshapableInput& input,
m_informative_timer = new QTimer(this);
connect(m_informative_timer, &QTimer::timeout, this, [this] {
// If the user has started moving we'll assume they know what they are doing.
if (*std::max_element(m_calibration_data.begin(), m_calibration_data.end()) > 0.5)
if (*std::ranges::max_element(m_calibration_data) > 0.5)
return;
ModalMessageBox::information(

View File

@ -846,7 +846,7 @@ void AssemblerWidget::CloseTab(int index, AsmEditor* editor)
int AssemblerWidget::AllocateTabNum()
{
auto min_it = std::min_element(m_free_editor_nums.begin(), m_free_editor_nums.end());
auto min_it = std::ranges::min_element(m_free_editor_nums);
if (min_it == m_free_editor_nums.end())
{
return m_unnamed_editor_count++;

View File

@ -481,7 +481,7 @@ void WatchWidget::DeleteSelectedWatches()
}
// Sort greatest to smallest, so we don't stomp on existing indices
std::sort(row_indices.begin(), row_indices.end(), std::greater{});
std::ranges::sort(row_indices, std::ranges::greater{});
for (const int row : row_indices)
{
DeleteWatch(guard, row);

View File

@ -192,8 +192,7 @@ void FIFOAnalyzer::UpdateTree()
// We shouldn't end on a Command (it should end with an EFB copy)
ASSERT(part_start == frame_info.parts.size());
// The counts we computed should match the frame's counts
ASSERT(std::equal(frame_info.part_type_counts.begin(), frame_info.part_type_counts.end(),
part_counts.begin()));
ASSERT(std::ranges::equal(frame_info.part_type_counts, part_counts));
}
}

View File

@ -130,8 +130,7 @@ void InterfacePane::CreateUI()
Common::DoFileSearch({File::GetUserPath(D_THEMES_IDX), File::GetSysDirectory() + THEMES_DIR});
std::vector<std::string> theme_names;
theme_names.reserve(theme_paths.size());
std::transform(theme_paths.cbegin(), theme_paths.cend(), std::back_inserter(theme_names),
PathToFileName);
std::ranges::transform(theme_paths, std::back_inserter(theme_names), PathToFileName);
// Theme Combobox
m_combobox_theme = new ConfigStringChoice(theme_names, Config::MAIN_THEME_NAME);

View File

@ -143,10 +143,10 @@ void ToolBar::MakeActions()
}
std::vector<int> widths;
std::transform(items.begin(), items.end(), std::back_inserter(widths),
[](QWidget* item) { return item->sizeHint().width(); });
std::ranges::transform(items, std::back_inserter(widths),
[](QWidget* item) { return item->sizeHint().width(); });
const int min_width = *std::max_element(widths.begin(), widths.end()) * 0.85;
const int min_width = *std::ranges::max_element(widths) * 0.85;
for (QWidget* widget : items)
widget->setMinimumWidth(min_width);
}