Special-case all lines being selected in validate_adjoinable

GetSortedSelection is kinda slow with large selections and all lines
being selected is an easy thing to special-case.
This commit is contained in:
Thomas Goyne 2014-12-24 16:59:08 -08:00
parent 44506eae56
commit c313f32384

View file

@ -60,10 +60,12 @@ struct validate_video_loaded : public Command {
struct validate_adjoinable : public Command { struct validate_adjoinable : public Command {
CMD_TYPE(COMMAND_VALIDATE) CMD_TYPE(COMMAND_VALIDATE)
bool Validate(const agi::Context *c) override { bool Validate(const agi::Context *c) override {
auto sel = c->selectionController->GetSortedSelection(); size_t sel_size = c->selectionController->GetSelectedSet().size();
if (sel.empty()) return false; if (sel_size == 0) return false;
if (sel_size == 1 || sel_size == c->ass->Events.size()) return true;
for (size_t i = 1; i < sel.size(); ++i) { auto sel = c->selectionController->GetSortedSelection();
for (size_t i = 1; i < sel_size; ++i) {
if (sel[i]->Row != sel[i - 1]->Row + 1) if (sel[i]->Row != sel[i - 1]->Row + 1)
return false; return false;
} }