diff --git a/src/base_grid.cpp b/src/base_grid.cpp index bedc9e775..1d3801c96 100644 --- a/src/base_grid.cpp +++ b/src/base_grid.cpp @@ -599,12 +599,14 @@ void BaseGrid::SetColumnWidths() { int x = 0; WidthHelper helper{dc, std::unordered_map, int>{}}; + helper.widths.reserve(prev_unique_string_widths); for (auto const& column : columns) { column->UpdateWidth(context, helper); if (column->Width() && column->RefreshOnTextChange()) text_refresh_rects.emplace_back(x, 0, column->Width(), h); x += column->Width(); } + prev_unique_string_widths = helper.widths.size(); } AssDialogue *BaseGrid::GetDialogue(int n) const { diff --git a/src/base_grid.h b/src/base_grid.h index 75d65993b..86ca3071d 100644 --- a/src/base_grid.h +++ b/src/base_grid.h @@ -57,6 +57,8 @@ class BaseGrid final : public wxWindow { int active_row = -1; + size_t prev_unique_string_widths = 0; + /// Rows which are visible on the current video frame std::vector visible_rows;