MCPcopy Create free account
hub / github.com/audacity/audacity / Calculate

Method Calculate

src/HistoryWindow.cpp:74–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72 Type clipboardSpaceUsage;
73
74 void Calculate( UndoManager &manager )
75 {
76 SampleBlockIDSet seen;
77
78 // After copies and pastes, a block file may be used in more than
79 // one place in one undo history state, and it may be used in more than
80 // one undo history state. It might even be used in two states, but not
81 // in another state that is between them -- as when you have state A,
82 // then make a cut to get state B, but then paste it back into state C.
83
84 // So be sure to count each block file once only, in the last undo item that
85 // contains it.
86
87 // Why the last and not the first? Because the user of the History dialog
88 // may DELETE undo states, oldest first. To reclaim disk space you must
89 // DELETE all states containing the block file. So the block file's
90 // contribution to space usage should be counted only in that latest
91 // state.
92
93 manager.VisitStates(
94 [this, &seen](const UndoStackElem &elem) {
95 // Scan all tracks at current level
96 if (auto pTracks = UndoTracks::Find(elem))
97 space.push_back(CalculateUsage(*pTracks, seen));
98 },
99 true // newest state first
100 );
101
102 // Count the usage of the clipboard separately, using another set. Do not
103 // multiple-count any block occurring multiple times within the clipboard.
104 seen.clear();
105 clipboardSpaceUsage = CalculateUsage(
106 Clipboard::Get().GetTracks(), seen);
107
108 //TIMER_STOP( space_calc );
109 }
110};
111}
112

Callers 3

DoUpdateMethod · 0.45
RecalcMethod · 0.45

Calls 5

FindFunction · 0.85
GetFunction · 0.85
VisitStatesMethod · 0.80
push_backMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected