From 3c27496b2936006fe48a232d80836ced657f2eda Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Mon, 27 Feb 2006 04:18:00 +0000 Subject: [PATCH] Added option ("keep raw dialogue data", default false) that makes Aegisub use less RAM at a small performance cost when set to false. Originally committed to SVN as r183. --- core/ass_dialogue.cpp | 36 ++++++++++++++++++++++++++++++++---- core/ass_dialogue.h | 9 +++++++++ core/ass_file.cpp | 4 ---- core/automation.cpp | 11 ++++++----- core/changelog.txt | 1 + core/main.cpp | 2 ++ core/options.cpp | 1 + 7 files changed, 51 insertions(+), 13 deletions(-) diff --git a/core/ass_dialogue.cpp b/core/ass_dialogue.cpp index dc14e3f6f..213e77b07 100644 --- a/core/ass_dialogue.cpp +++ b/core/ass_dialogue.cpp @@ -47,6 +47,7 @@ #include "FexMovement.h" #endif + ////////////////////// AssDialogue ////////////////////// // Constructs AssDialogue AssDialogue::AssDialogue() { @@ -202,9 +203,14 @@ bool AssDialogue::Parse(wxString rawData, bool IsSSA) { } -////////////////////////////////// -// Update AssDialogue's data line -void AssDialogue::UpdateData () { +////////////////// +// Keep data flag +bool AssDialogue::keepData = true; + + +///////////// +// Make data +wxString AssDialogue::MakeData() { // Prepare wxString final = _T(""); @@ -233,7 +239,29 @@ void AssDialogue::UpdateData () { Effect.Replace(_T(","),_T(";")); final += Effect + _T(","); final += Text; - SetEntryData(final); + return final; +} + + +////////////////////////////////// +// Update AssDialogue's data line +void AssDialogue::UpdateData () { + if (keepData) SetEntryData(MakeData()); +} + + +////////////////// +// Get entry data +const wxString AssDialogue::GetEntryData() { + if (keepData) return AssEntry::GetEntryData(); + return MakeData(); +} + + +////////////////// +// Set entry data +void AssDialogue::SetEntryData(wxString newData) { + if (keepData) AssEntry::SetEntryData(newData); } diff --git a/core/ass_dialogue.h b/core/ass_dialogue.h index 01371ece9..334ec90f9 100644 --- a/core/ass_dialogue.h +++ b/core/ass_dialogue.h @@ -155,7 +155,12 @@ public: //////////////////////////////////////// // Class for Dialogue and Comment lines class AssDialogue : public AssEntry { +private: + wxString MakeData(); + public: + static bool keepData; + std::vector Blocks; // Contains information about each block of text bool Comment; // Is this a comment line? @@ -179,8 +184,12 @@ public: bool Parse(wxString data,bool IsSSA=false); // Parses raw ASS data into everything else void ParseASSTags(); // Parses text to generate block information (doesn't update data) void ParseSRTTags(); // Converts tags to ass format and calls ParseASSTags+UpdateData + void UpdateData(); // Updates raw data from current values + text void UpdateText(); // Generates text from the override tags + const wxString GetEntryData(); + void SetEntryData(wxString newData); + void ConvertTagsToSRT(); // Converts tags to SRT format void StripTags(); // Strips all tags from the text void Clear(); // Wipes all data diff --git a/core/ass_file.cpp b/core/ass_file.cpp index 99f9d4cd7..477ff5ae1 100644 --- a/core/ass_file.cpp +++ b/core/ass_file.cpp @@ -678,10 +678,6 @@ wxArrayString AssFile::GetStyles() { if (curstyle) { styles.Add(curstyle->name); } - if (!curstyle && (*cur)->GetEntryData().Left(5) == _T("Style")) { - wxLogMessage(_T("Style ignored: ") + (*cur)->GetEntryData()); - curstyle = AssEntry::GetAsStyle(*cur); - } } if (styles.GetCount() == 0) styles.Add(_T("Default")); return styles; diff --git a/core/automation.cpp b/core/automation.cpp index bd0a95eac..487bb26ca 100644 --- a/core/automation.cpp +++ b/core/automation.cpp @@ -1252,14 +1252,15 @@ void AutomationScript::process_lines(AssFile *input) // not a dialogue/comment event // start checking for a blank line - if (e->GetEntryData().IsEmpty()) { + wxString entryData = e->GetEntryData(); + if (entryData.IsEmpty()) { lua_newtable(L); L_settable(L, -1, "kind", wxString(_T("blank"))); - } else if (e->GetEntryData()[0] == _T(';')) { + } else if (entryData[0] == _T(';')) { // semicolon comment lua_newtable(L); L_settable(L, -1, "kind", wxString(_T("scomment"))); - L_settable(L, -1, "text", e->GetEntryData().Mid(1)); + L_settable(L, -1, "text", entryData.Mid(1)); } else { // not a blank line and not a semicolon comment // just skip... @@ -1435,11 +1436,11 @@ void AutomationScript::process_lines(AssFile *input) while (next != input->Line.end()) { cur = next++; if ((*cur)->group == _T("[Events]")) { - if ((*cur)->GetEntryData() == _T("[Events]")) { + wxString temp = (*cur)->GetEntryData(); + if (temp == _T("[Events]")) { // skip the section header continue; } - wxString temp = (*cur)->GetEntryData(); if ((*cur)->GetType() != ENTRY_DIALOGUE && temp.Mid(0,1) != _T(";") && temp.Trim() != _T("")) { // skip non-dialogue non-semicolon comment lines (such as Format) continue; diff --git a/core/changelog.txt b/core/changelog.txt index e778b7136..ba94f2042 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -52,6 +52,7 @@ Please visit http://aegisub.net to download latest version - Better error reporting when loading Automation scripts (jfs) - Attempting to load a file which does not exist no longer unloads previous subtitles. (AMZ) - Dragging timecode files into the Aegisub window will now work as expected (instead of attempting to load it as subtitles). (AMZ) +- Added option ("keep raw dialogue data", default false) that makes Aegisub use less RAM at a small performance cost when set to false. (AMZ) = 1.09 beta - 2006.01.16 =========================== diff --git a/core/main.cpp b/core/main.cpp index 9b11fe8e1..a9e8ccdf8 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -51,6 +51,7 @@ #include "export_framerate.h" #include "ass_export_filter.h" #include "ass_time.h" +#include "ass_dialogue.h" #include "subs_grid.h" @@ -80,6 +81,7 @@ bool AegisubApp::OnInit() { Options.SetFile(folderName + _T("/config.dat")); Options.Load(); AssTime::UseMSPrecision = Options.AsBool(_T("Use nonstandard Milisecond Times")); + AssDialogue::keepData = Options.AsBool(_T("Keep raw dialogue data")); // Set hotkeys file Hotkeys.SetFile(folderName + _T("/hotkeys.dat")); diff --git a/core/options.cpp b/core/options.cpp index 8deb8cc67..859df8011 100644 --- a/core/options.cpp +++ b/core/options.cpp @@ -69,6 +69,7 @@ void OptionsManager::LoadDefaults() { SetInt(_T("Locale Code"),-1); SetText(_T("Save Charset"),_T("UTF-8")); SetBool(_T("Use nonstandard Milisecond Times"),false); + SetBool(_T("Keep raw dialogue data"),false); SetInt(_T("Undo Levels"),8); SetInt(_T("Recent sub max"),16);