From 744717a164ab0013f264cc1d21a2632c21270e56 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 18 Apr 2014 14:08:12 -0700 Subject: [PATCH] Skip calculating the CPS for lines where it's very unlikely to be meaningful --- src/grid_column.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/grid_column.cpp b/src/grid_column.cpp index 1e1315d60..468c2d6cd 100644 --- a/src/grid_column.cpp +++ b/src/grid_column.cpp @@ -225,7 +225,12 @@ struct GridColumnCPS final : GridColumn { wxString Value(const AssDialogue *d, const agi::Context *) const override { int characters = 0; + int duration = d->End - d->Start; auto const& text = d->Text.get(); + + if (duration <= 0 || text.size() > static_cast(duration)) + return wxS(""); + auto pos = begin(text); do { auto it = std::find(pos, end(text), '{'); @@ -239,11 +244,7 @@ struct GridColumnCPS final : GridColumn { } } while (++pos != end(text)); - int duration = d->End - d->Start; - if (duration <= 0 || characters * 1000 / duration >= 1000) - return wxS(""); - else - return std::to_wstring(characters * 1000 / duration); + return std::to_wstring(characters * 1000 / duration); } int Width(const agi::Context *c, WidthHelper &helper, bool) const override {