mirror of
https://github.com/fadden/6502bench.git
synced 2025-03-03 14:32:06 +00:00
Make ResetList() 1000x faster
Rather than sending 540,000 "item has changed" events, send a single "collection reset" message.
This commit is contained in:
parent
a7d66e67e0
commit
da825d3114
@ -371,7 +371,7 @@ namespace SourceGen {
|
||||
highAscii.DebugDump("High-ASCII (" + DataAnalysis.MIN_STRING_LENGTH + "+)");
|
||||
}
|
||||
Debug.WriteLine("ScanFileData took " +
|
||||
((DateTime.Now - startWhen).Milliseconds) + " ms");
|
||||
((DateTime.Now - startWhen).TotalMilliseconds) + " ms");
|
||||
|
||||
RepeatedBytes = repeats;
|
||||
StdAsciiBytes = ascii;
|
||||
|
@ -371,7 +371,7 @@ namespace SourceGenWPF {
|
||||
highAscii.DebugDump("High-ASCII (" + DataAnalysis.MIN_STRING_LENGTH + "+)");
|
||||
}
|
||||
Debug.WriteLine("ScanFileData took " +
|
||||
((DateTime.Now - startWhen).Milliseconds) + " ms");
|
||||
((DateTime.Now - startWhen).TotalMilliseconds) + " ms");
|
||||
|
||||
RepeatedBytes = repeats;
|
||||
StdAsciiBytes = ascii;
|
||||
|
@ -258,12 +258,23 @@ namespace SourceGenWPF {
|
||||
return parts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the list, filling it with empty elements.
|
||||
/// </summary>
|
||||
/// <param name="size">New size of the list.</param>
|
||||
public void ResetList(int size) {
|
||||
// TODO: can we recycle existing elements and just add/trim as needed?
|
||||
Clear();
|
||||
mList.Capacity = size;
|
||||
for (int i = 0; i < size; i++) {
|
||||
Add(null);
|
||||
// add directly to list so we don't send events
|
||||
mList.Add(null);
|
||||
}
|
||||
|
||||
// send one big notification at the end; "reset" means "forget everything you knew"
|
||||
OnPropertyChanged(CountString);
|
||||
OnPropertyChanged(IndexerName);
|
||||
OnCollectionReset();
|
||||
}
|
||||
|
||||
public class FormattedParts {
|
||||
|
@ -74,8 +74,8 @@ namespace SourceGenWPF.ProjWin {
|
||||
// state of Items collection.
|
||||
PresentationTraceSources.SetTraceLevel(codeListView.ItemContainerGenerator,
|
||||
PresentationTraceLevel.High);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// INotifyPropertyChanged event
|
||||
@ -150,7 +150,7 @@ namespace SourceGenWPF.ProjWin {
|
||||
//codeListView.SelectedItems.Clear();
|
||||
//listViewSetSelectedItems.Invoke(codeListView, new object[] { codeListView.Items });
|
||||
|
||||
Debug.WriteLine("Select All cmd: " + (DateTime.Now - start).Milliseconds + " ms");
|
||||
Debug.WriteLine("Select All cmd: " + (DateTime.Now - start).TotalMilliseconds + " ms");
|
||||
}
|
||||
|
||||
private void RecentProjectCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user