Eliminate a bunch of pointless copies of the selection set

This commit is contained in:
Thomas Goyne 2014-03-12 14:54:46 -07:00
parent 31979500c4
commit 92ae789b46
6 changed files with 12 additions and 14 deletions

View File

@ -732,7 +732,7 @@ void AudioTimingControllerDialogue::RegenerateInactiveLines()
bool was_empty = inactive_lines.empty();
inactive_lines.clear();
SubtitleSelection sel = context->selectionController->GetSelectedSet();
SubtitleSelection const& sel = context->selectionController->GetSelectedSet();
switch (int mode = inactive_line_mode->GetInt())
{
@ -794,7 +794,7 @@ void AudioTimingControllerDialogue::RegenerateSelectedLines()
selected_lines.clear();
AssDialogue *active = context->selectionController->GetActiveLine();
SubtitleSelection sel = context->selectionController->GetSelectedSet();
SubtitleSelection const& sel = context->selectionController->GetSelectedSet();
for (auto line : sel)
{
if (line == active) continue;

View File

@ -195,7 +195,7 @@ struct audio_save_clip : public Command {
}
void operator()(agi::Context *c) override {
SubtitleSelection sel = c->selectionController->GetSelectedSet();
SubtitleSelection const& sel = c->selectionController->GetSelectedSet();
if (sel.empty()) return;
AssTime start = INT_MAX, end = 0;

View File

@ -488,7 +488,7 @@ struct edit_find_replace : public Command {
static std::string get_entry_data(AssDialogue &d) { return d.GetEntryData(); }
static void copy_lines(agi::Context *c) {
SubtitleSelection sel = c->selectionController->GetSelectedSet();
SubtitleSelection const& sel = c->selectionController->GetSelectedSet();
SetClipboard(join(c->ass->Events
| filtered([&](AssDialogue &d) { return sel.count(&d); })
| transformed(get_entry_data),
@ -496,7 +496,7 @@ static void copy_lines(agi::Context *c) {
}
static void delete_lines(agi::Context *c, wxString const& commit_message) {
SubtitleSelection sel = c->selectionController->GetSelectedSet();
SubtitleSelection const& sel = c->selectionController->GetSelectedSet();
// Find a line near the active line not being deleted to make the new active line
AssDialogue *pre_sel = nullptr;
@ -693,7 +693,7 @@ struct edit_line_duplicate_shift_back : public validate_video_and_sel_nonempty {
};
static void combine_lines(agi::Context *c, void (*combiner)(AssDialogue *, AssDialogue *), wxString const& message) {
SubtitleSelection sel = c->selectionController->GetSelectedSet();
SubtitleSelection const& sel = c->selectionController->GetSelectedSet();
AssDialogue *first = nullptr;
for (auto it = c->ass->Events.begin(); it != c->ass->Events.end(); ) {
@ -709,9 +709,7 @@ static void combine_lines(agi::Context *c, void (*combiner)(AssDialogue *, AssDi
delete diag;
}
sel.clear();
sel.insert(first);
c->selectionController->SetSelectionAndActive(sel, first);
c->selectionController->SetSelectionAndActive({first}, first);
c->ass->Commit(message, AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL);
}
@ -922,7 +920,7 @@ struct edit_line_recombine : public validate_sel_multiple {
STR_HELP("Recombine subtitles which have been split and merged")
void operator()(agi::Context *c) override {
auto sel_set = c->selectionController->GetSelectedSet();
auto const& sel_set = c->selectionController->GetSelectedSet();
if (sel_set.size() < 2) return;
auto active_line = c->selectionController->GetActiveLine();

View File

@ -389,7 +389,7 @@ struct grid_swap : public Command {
}
void operator()(agi::Context *c) override {
SubtitleSelection sel = c->selectionController->GetSelectedSet();
SubtitleSelection const& sel = c->selectionController->GetSelectedSet();
if (sel.size() == 2) {
(*sel.begin())->swap_nodes(**sel.rbegin());
c->ass->Commit(_("swap lines"), AssFile::COMMIT_ORDER);

View File

@ -62,7 +62,7 @@ namespace {
struct validate_adjoinable : public Command {
CMD_TYPE(COMMAND_VALIDATE)
bool Validate(const agi::Context *c) override {
SubtitleSelection sel = c->selectionController->GetSelectedSet();
SubtitleSelection const& sel = c->selectionController->GetSelectedSet();
if (sel.size() < 2) return !sel.empty();
size_t found = 0;
@ -79,7 +79,7 @@ namespace {
};
static void adjoin_lines(agi::Context *c, bool set_start) {
auto sel = c->selectionController->GetSelectedSet();
auto const& sel = c->selectionController->GetSelectedSet();
AssDialogue *prev = nullptr;
size_t seen = 0;
bool prev_sel = false;

View File

@ -332,7 +332,7 @@ void DialogShiftTimes::Process(wxCommandEvent &) {
bool start = type != 2;
bool end = type != 1;
SubtitleSelection sel = context->selectionController->GetSelectedSet();
SubtitleSelection const& sel = context->selectionController->GetSelectedSet();
long shift;
if (by_time) {