Skip calculating the CPS for lines where it's very unlikely to be meaningful

This commit is contained in:
Thomas Goyne 2014-04-18 14:08:12 -07:00
parent 5143c34d70
commit 744717a164
1 changed files with 6 additions and 5 deletions

View File

@ -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<size_t>(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 {