From d759aae2b354af2866562c638ba2706e60138326 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Tue, 21 Feb 2006 21:52:32 +0000 Subject: [PATCH] Some small improvements to RAM usage Originally committed to SVN as r99. --- core/ass_file.cpp | 22 ++++++++++++++++++++++ core/ass_file.h | 1 + core/changelog.txt | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/core/ass_file.cpp b/core/ass_file.cpp index 2f65167fb..af3472432 100644 --- a/core/ass_file.cpp +++ b/core/ass_file.cpp @@ -924,6 +924,23 @@ void AssFile::AddToRecent(wxString file) { } +//////////////////////////////////////////// +// Compress/decompress for storage on stack +void AssFile::CompressForStack(bool compress) { + AssDialogue *diag; + for (entryIter cur=Line.begin();cur!=Line.end();cur++) { + diag = AssEntry::GetAsDialogue(*cur); + if (diag) { + if (compress) { + diag->data.Clear(); + diag->ClearBlocks(); + } + else diag->UpdateData(); + } + } +} + + ////////////////////////////// // Checks if file is modified bool AssFile::IsModified() { @@ -954,6 +971,7 @@ void AssFile::FlagAsModified() { void AssFile::StackPush() { // Places copy on stack AssFile *curcopy = new AssFile(*top); + curcopy->CompressForStack(true); UndoStack.push_back(curcopy); StackModified = true; @@ -983,8 +1001,10 @@ void AssFile::StackPop() { if (!UndoStack.empty()) { //delete top; + top->CompressForStack(true); RedoStack.push_back(top); top = UndoStack.back(); + top->CompressForStack(false); UndoStack.pop_back(); Popping = true; } @@ -1007,8 +1027,10 @@ void AssFile::StackRedo() { } if (!RedoStack.empty()) { + top->CompressForStack(true); UndoStack.push_back(top); top = RedoStack.back(); + top->CompressForStack(false); RedoStack.pop_back(); Popping = true; //StackModified = false; diff --git a/core/ass_file.h b/core/ass_file.h index fd53798c4..a18d05e33 100644 --- a/core/ass_file.h +++ b/core/ass_file.h @@ -97,6 +97,7 @@ public: bool IsModified(); // Returns if file has unmodified changes void FlagAsModified(); // Flag file as being modified, will automatically put a copy on stack void Clear(); // Wipes file + void CompressForStack(bool compress); // Compress/decompress for storage on stack void LoadDefault(bool noline=true); // Loads default file. Pass true to prevent it from adding a default line too void InsertStyle(AssStyle *style); // Inserts a style to file wxArrayString GetStyles(); // Gets a list of all styles available diff --git a/core/changelog.txt b/core/changelog.txt index f9cbcd07a..df012384d 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -39,7 +39,7 @@ Please visit http://aegisub.net to download latest version - Added a simple audio resync method afor video playback. (AMZ) - Audio timing will now apply to all selected lines, as well as active line. (AMZ) - Added a volume slider bar to audio mode. (AMZ) -- Fixed some internal workings, which should make Aegisub use considerably less RAM (especially for large Karaoke files, 3x less RAM usage measured). (AMZ) +- Fixed some internal workings, which should make Aegisub use considerably less RAM (especially for large Karaoke files, 3-4x less RAM usage was measured with a 9 MB file). (AMZ) - Aegisub will now dump the stack to stack.txt when it crashes with a fatal exception, which might or might not work. (AMZ) - Audio display in SSA mode will no longer ignore clicks if it wasn't focused (AMZ)