From 8c1b20e651aa8a7786c40743688cbc5cf1ea7ad6 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sat, 31 Jan 2015 20:09:35 -0800 Subject: [PATCH] Speed up grid painting with many unique effects/actors a bit --- src/base_grid.cpp | 2 ++ src/base_grid.h | 2 ++ 2 files changed, 4 insertions(+) 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;