mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-19 17:11:12 +02:00
Calculate space usage for a state frame (UndoStackElem) in UndoManager::PushState, i.e., only when the UndoStackElem is created, rather than every time we open History Window. This should considerably speed up opening History Window when the stack is large (many frames and/or lots of data), and fix bug 196.
This commit is contained in:
@@ -49,7 +49,7 @@ UndoManager::~UndoManager()
|
||||
// get the sum of the sizes of all blocks this track list
|
||||
// references. However, if a block is referred to multiple
|
||||
// times it is only counted once. Return value is in bytes.
|
||||
wxLongLong UndoManager::GetSpaceUsage(int index)
|
||||
wxLongLong UndoManager::CalculateSpaceUsage(int index)
|
||||
{
|
||||
TrackListOfKindIterator iter(Track::Wave);
|
||||
WaveTrack *wt;
|
||||
@@ -113,7 +113,7 @@ void UndoManager::GetLongDescription(unsigned int n, wxString *desc,
|
||||
|
||||
*desc = stack[n]->description;
|
||||
|
||||
*size = Internat::FormatSize(GetSpaceUsage(n));
|
||||
*size = Internat::FormatSize(stack[n]->spaceUsage);
|
||||
}
|
||||
|
||||
void UndoManager::GetShortDescription(unsigned int n, wxString *desc)
|
||||
@@ -243,9 +243,11 @@ void UndoManager::PushState(TrackList * l, double sel0, double sel1,
|
||||
push->sel1 = sel1;
|
||||
push->description = longDescription;
|
||||
push->shortDescription = shortDescription;
|
||||
push->spaceUsage = 0; // Calculate actual value after it's on the stack.
|
||||
|
||||
stack.Add(push);
|
||||
current++;
|
||||
push->spaceUsage = this->CalculateSpaceUsage(current);
|
||||
|
||||
if (saved >= current) {
|
||||
saved = -1;
|
||||
|
@@ -61,6 +61,7 @@ struct UndoStackElem {
|
||||
wxString shortDescription;
|
||||
double sel0;
|
||||
double sel1;
|
||||
wxLongLong spaceUsage;
|
||||
};
|
||||
|
||||
WX_DEFINE_USER_EXPORTED_ARRAY(UndoStackElem *, UndoStack, class AUDACITY_DLL_API);
|
||||
@@ -102,7 +103,7 @@ class AUDACITY_DLL_API UndoManager {
|
||||
void ResetODChangesFlag();
|
||||
|
||||
private:
|
||||
wxLongLong GetSpaceUsage(int index);
|
||||
wxLongLong CalculateSpaceUsage(int index);
|
||||
|
||||
int current;
|
||||
int saved;
|
||||
|
Reference in New Issue
Block a user