1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-02 14:17:07 +01:00

Bug 765 - Delays using Edit commands and Draw Tool in long projects

A 4hr track used to take about 20s to cut a few samples. This is now significantly improved, to around 3s. Leland did this by

(a) moving the size calculation to when we examine the undo history, so it isn't slowing down the edits.
(b) in size calculation, using sizes that are cached rather than going to disk to find the sizes.
(c) writing the autosave file which is to an FFIle to a string first, i.e. using XMLStringWriter as a buffer for XMLFileWriter.

Step (c) may also make autosave marginally safer, as the risk of a partially updated autosave file is reduced.
This commit is contained in:
Leland Lucius
2015-04-07 12:20:50 +01:00
committed by James Crook
parent cedc6975e8
commit 2457579091
12 changed files with 79 additions and 88 deletions

View File

@@ -61,18 +61,17 @@ struct UndoStackElem {
wxString description;
wxString shortDescription;
SelectedRegion selectedRegion;
wxLongLong spaceUsage;
};
WX_DEFINE_USER_EXPORTED_ARRAY(UndoStackElem *, UndoStack, class AUDACITY_DLL_API);
WX_DEFINE_USER_EXPORTED_ARRAY_SIZE_T(size_t, SpaceArray, class AUDACITY_DLL_API);
// These flags control what extra to do on a PushState
// Default is PUSH_AUTOSAVE | PUSH_CALC_SPACE
// Default is PUSH_AUTOSAVE
// Frequent/faster actions use PUSH_CONSOLIDATE
const int PUSH_MINIMAL = 0;
const int PUSH_CONSOLIDATE = 1;
const int PUSH_CALC_SPACE = 2;
const int PUSH_AUTOSAVE = 4;
const int PUSH_AUTOSAVE = 2;
class AUDACITY_DLL_API UndoManager {
public:
@@ -82,7 +81,7 @@ class AUDACITY_DLL_API UndoManager {
void PushState(TrackList * l,
const SelectedRegion &selectedRegion,
wxString longDescription, wxString shortDescription,
int flags = PUSH_CALC_SPACE|PUSH_AUTOSAVE );
int flags = PUSH_AUTOSAVE);
void ModifyState(TrackList * l,
const SelectedRegion &selectedRegion);
void ClearStates();
@@ -105,6 +104,8 @@ class AUDACITY_DLL_API UndoManager {
bool UnsavedChanges();
void StateSaved();
void CalculateSpaceUsage();
// void Debug(); // currently unused
///to mark as unsaved changes without changing the state/tracks.
@@ -113,8 +114,6 @@ class AUDACITY_DLL_API UndoManager {
void ResetODChangesFlag();
private:
wxLongLong CalculateSpaceUsage(int index);
int current;
int saved;
UndoStack stack;
@@ -122,6 +121,8 @@ class AUDACITY_DLL_API UndoManager {
wxString lastAction;
int consolidationCount;
SpaceArray space;
bool mODChanges;
ODLock mODChangesMutex;//mODChanges is accessed from many threads.