diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2021-02-23 17:06:07 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-24 21:02:02 +0100 |
commit | 6a6f19a72fe15c05c39a53fa5be2b4ca3d65edf3 (patch) | |
tree | 1cf15372919c835422931d6adf3e1bac4268761e /Userland/Applications/Spreadsheet/SpreadsheetView.cpp | |
parent | 98f08a8badccc216b0ef339c162a579a81a12417 (diff) | |
download | serenity-6a6f19a72fe15c05c39a53fa5be2b4ca3d65edf3.zip |
Spreadsheet: Store the column index in a Position instead of its name
This will make constructing (and destructing) Positions a lot cheaper
(as it no longer needs to ref() and unref() a String).
Resulted from #5483, but doesn't fix it.
Diffstat (limited to 'Userland/Applications/Spreadsheet/SpreadsheetView.cpp')
-rw-r--r-- | Userland/Applications/Spreadsheet/SpreadsheetView.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp index 45dbf275a2..1a28d81362 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp @@ -57,7 +57,7 @@ void SpreadsheetView::EditingDelegate::set_value(const GUI::Variant& value) return StringModelEditingDelegate::set_value(value); m_has_set_initial_value = true; - const auto option = m_sheet.at({ m_sheet.column(index().column()), (size_t)index().row() }); + const auto option = m_sheet.at({ (size_t)index().column(), (size_t)index().row() }); if (option) return StringModelEditingDelegate::set_value(option->source()); @@ -198,7 +198,7 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet) m_table_view->on_selection_change = [&] { m_sheet->selected_cells().clear(); for (auto& index : m_table_view->selection().indexes()) { - Position position { m_sheet->column(index.column()), (size_t)index.row() }; + Position position { (size_t)index.column(), (size_t)index.row() }; m_sheet->selected_cells().set(position); } @@ -208,7 +208,7 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet) Vector<Position> selected_positions; selected_positions.ensure_capacity(m_table_view->selection().size()); for (auto& selection : m_table_view->selection().indexes()) - selected_positions.empend(m_sheet->column(selection.column()), (size_t)selection.row()); + selected_positions.empend((size_t)selection.column(), (size_t)selection.row()); if (on_selection_changed) { on_selection_changed(move(selected_positions)); @@ -229,13 +229,13 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet) m_cell_range_context_menu->add_action(GUI::Action::create("Type and Formatting...", [this](auto&) { Vector<Position> positions; for (auto& index : m_table_view->selection().indexes()) { - Position position { m_sheet->column(index.column()), (size_t)index.row() }; + Position position { (size_t)index.column(), (size_t)index.row() }; positions.append(move(position)); } if (positions.is_empty()) { auto& index = m_table_view->cursor_index(); - Position position { m_sheet->column(index.column()), (size_t)index.row() }; + Position position { (size_t)index.column(), (size_t)index.row() }; positions.append(move(position)); } @@ -270,7 +270,7 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet) } // Drop always has a single target. - Position target { m_sheet->column(index.column()), (size_t)index.row() }; + Position target { (size_t)index.column(), (size_t)index.row() }; target_positions.append(move(target)); if (source_positions.is_empty()) @@ -283,7 +283,7 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet) } if (event.mime_data().has_text()) { - auto* target_cell = m_sheet->at({ m_sheet->column(index.column()), (size_t)index.row() }); + auto* target_cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); VERIFY(target_cell); target_cell->set_data(event.text()); @@ -304,7 +304,7 @@ void SpreadsheetView::show_event(GUI::ShowEvent&) Vector<Position> selected_positions; selected_positions.ensure_capacity(m_table_view->selection().size()); for (auto& selection : m_table_view->selection().indexes()) - selected_positions.empend(m_sheet->column(selection.column()), (size_t)selection.row()); + selected_positions.empend((size_t)selection.column(), (size_t)selection.row()); on_selection_changed(move(selected_positions)); } |