Eliminate a pointless set that only ever had zero or one entries

This commit is contained in:
Thomas Goyne 2014-12-28 12:06:15 -08:00
parent 5201773a3b
commit 372b9fe115
8 changed files with 18 additions and 27 deletions

View File

@ -177,11 +177,7 @@ int AssFile::Commit(wxString const& desc, int type, int amend_id, AssDialogue *s
PushState({desc, &amend_id, single_line});
std::set<const AssDialogue*> changed_lines;
if (single_line)
changed_lines.insert(single_line);
AnnounceCommit(type, changed_lines);
AnnounceCommit(type, single_line);
return amend_id;
}

View File

@ -80,7 +80,7 @@ struct ProjectProperties {
class AssFile {
/// A set of changes has been committed to the file (AssFile::COMMITType)
agi::signal::Signal<int, std::set<const AssDialogue*> const&> AnnounceCommit;
agi::signal::Signal<int, const AssDialogue*> AnnounceCommit;
agi::signal::Signal<AssFileCommit> PushState;
public:
/// The lines in the file

View File

@ -115,24 +115,19 @@ void AsyncVideoProvider::LoadSubtitles(const AssFile *new_subs) throw() {
});
}
void AsyncVideoProvider::UpdateSubtitles(const AssFile *new_subs, std::set<const AssDialogue*> const& changes) throw() {
void AsyncVideoProvider::UpdateSubtitles(const AssFile *new_subs, const AssDialogue *changed) throw() {
uint_fast32_t req_version = ++version;
// Copy just the lines which were changed, then replace the lines at the
// same indices in the worker's copy of the file with the new entries
std::vector<AssDialogue *> changed;
for (auto d : changes)
changed.push_back(new AssDialogue(*d));
// Copy just the line which were changed, then replace the line at the
// same index in the worker's copy of the file with the new entry
auto copy = new AssDialogue(*changed);
worker->Async([=]{
int i = 0;
auto it = subs->Events.begin();
for (auto& update : changed) {
std::advance(it, update->Row - i);
i = update->Row;
subs->Events.insert(it, *update);
delete &*it--;
}
std::advance(it, copy->Row - i);
i = copy->Row;
subs->Events.insert(it, *copy);
delete &*it--;
single_frame = NEW_SUBS_FILE;
ProcAsync(req_version, true);

View File

@ -92,7 +92,7 @@ public:
///
/// This function only supports changes to existing lines, and not
/// insertions or deletions.
void UpdateSubtitles(const AssFile *subs, std::set<const AssDialogue *> const& changes) throw();
void UpdateSubtitles(const AssFile *subs, const AssDialogue *changes) throw();
/// @brief Queue a request for a frame
/// @brief frame Frame number

View File

@ -113,8 +113,8 @@ void AudioKaraoke::OnActiveLineChanged(AssDialogue *new_line) {
}
}
void AudioKaraoke::OnFileChanged(int type, std::set<const AssDialogue *> const& changed) {
if (enabled && (type & AssFile::COMMIT_DIAG_FULL) && (changed.empty() || changed.count(active_line))) {
void AudioKaraoke::OnFileChanged(int type, const AssDialogue *changed) {
if (enabled && (type & AssFile::COMMIT_DIAG_FULL) && (!changed || changed == active_line)) {
LoadFromLine();
split_area->Refresh(false);
}

View File

@ -137,7 +137,7 @@ class AudioKaraoke final : public wxWindow {
void OnActiveLineChanged(AssDialogue *new_line);
void OnContextMenu(wxContextMenuEvent&);
void OnEnableButton(wxCommandEvent &evt);
void OnFileChanged(int type, std::set<const AssDialogue *> const& changed);
void OnFileChanged(int type, const AssDialogue *changed);
void OnMouse(wxMouseEvent &event);
void OnPaint(wxPaintEvent &event);
void OnSize(wxSizeEvent &event);

View File

@ -65,7 +65,7 @@ void VideoController::OnNewVideoProvider(AsyncVideoProvider *new_provider) {
color_matrix = provider ? provider->GetColorSpace() : "";
}
void VideoController::OnSubtitlesCommit(int type, std::set<const AssDialogue *> const& changed) {
void VideoController::OnSubtitlesCommit(int type, const AssDialogue *changed) {
if (!provider) return;
if ((type & AssFile::COMMIT_SCRIPTINFO) || type == AssFile::COMMIT_NEW) {
@ -76,10 +76,10 @@ void VideoController::OnSubtitlesCommit(int type, std::set<const AssDialogue *>
}
}
if (changed.empty())
if (!changed)
provider->LoadSubtitles(context->ass.get());
else
provider->UpdateSubtitles(context->ass.get(), changed);
provider->UpdateSubtitles(context->ass.get(), {changed});
}
void VideoController::OnActiveLineChanged(AssDialogue *line) {

View File

@ -104,7 +104,7 @@ class VideoController final : public wxEvtHandler {
void OnVideoError(VideoProviderErrorEvent const& err);
void OnSubtitlesError(SubtitlesProviderErrorEvent const& err);
void OnSubtitlesCommit(int type, std::set<const AssDialogue *> const& changed);
void OnSubtitlesCommit(int type, const AssDialogue *changed);
void OnNewVideoProvider(AsyncVideoProvider *provider);
void OnActiveLineChanged(AssDialogue *line);