summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-31 00:38:42 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-31 00:45:43 +0100
commit91493be4f3fcebd6a3c2c52fdd8beb3aa1121888 (patch)
tree41cf36ebc9cd6c3af54f52527cb415c3ca0061e3 /Libraries/LibGUI
parent34b3d92a13f154d3560c79e16a2e370fddbf130e (diff)
downloadserenity-91493be4f3fcebd6a3c2c52fdd8beb3aa1121888.zip
LibGUI: Simplify FontPicker::set_font()
Use Vector::find_first_index() instead of iterating manually. :^)
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r--Libraries/LibGUI/FontPicker.cpp27
1 files changed, 3 insertions, 24 deletions
diff --git a/Libraries/LibGUI/FontPicker.cpp b/Libraries/LibGUI/FontPicker.cpp
index e3316fce79..e7686558ee 100644
--- a/Libraries/LibGUI/FontPicker.cpp
+++ b/Libraries/LibGUI/FontPicker.cpp
@@ -154,34 +154,13 @@ void FontPicker::set_font(const Gfx::Font* font)
m_weight = font->weight();
m_size = font->presentation_size();
- size_t family_index = 0;
- for (size_t i = 0; i < m_families.size(); ++i) {
- if (m_families[i] == m_font->family()) {
- family_index = i;
- break;
- }
- }
-
+ size_t family_index = m_families.find_first_index(m_font->family()).value();
m_family_list_view->set_cursor(m_family_list_view->model()->index(family_index), GUI::AbstractView::SelectionUpdate::Set);
- size_t weight_index = 0;
- for (size_t i = 0; i < m_weights.size(); ++i) {
- if (m_weights[i] == m_font->weight()) {
- weight_index = i;
- break;
- }
- }
-
+ size_t weight_index = m_weights.find_first_index(m_font->weight()).value();
m_weight_list_view->set_cursor(m_weight_list_view->model()->index(weight_index), GUI::AbstractView::SelectionUpdate::Set);
- size_t size_index = 0;
- for (size_t i = 0; i < m_sizes.size(); ++i) {
- if (m_sizes[i] == m_font->presentation_size()) {
- size_index = i;
- break;
- }
- }
-
+ size_t size_index = m_sizes.find_first_index(m_font->presentation_size()).value();
m_size_list_view->set_cursor(m_size_list_view->model()->index(size_index), GUI::AbstractView::SelectionUpdate::Set);
}