Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yatima1460 committed May 15, 2024
1 parent c515ba0 commit 4abc790
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
14 changes: 8 additions & 6 deletions Core/Heuristics.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

using System.Collections.Immutable;

using System.Diagnostics;
using System.Reflection;


Expand All @@ -20,19 +20,21 @@ static Heuristics()

if (resourceName == null)
{
Console.WriteLine("Can't find words dictionary in embedded resources");
Debug.WriteLine("Can't find words dictionary in embedded resources");
dict = [];
return;
}

using var stream = assembly.GetManifestResourceStream(resourceName);
if (stream != null)
if (stream == null)
{
using var reader = new StreamReader(stream);
dict = reader.ReadToEnd().Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToImmutableHashSet<string>();
Debug.WriteLine("words dictionary resource stream is null");
dict = [];
return;
}

dict = [];
using var reader = new StreamReader(stream);
dict = [.. reader.ReadToEnd().Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)];
}


Expand Down
14 changes: 9 additions & 5 deletions WinForms/SearchWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public SearchWindow()

Search drillSearch = new("");

//TODO: replace this with ListViewItem
private readonly Dictionary<FileSystemInfo, DrillResult> itemsCache = new();

private readonly List<FileSystemInfo> resultsBag = new(100);


Dictionary<string, int> extensionIconCache = new(100);

int oldResultsCount = 0;
Expand Down Expand Up @@ -127,7 +128,6 @@ private ListViewItem CreateListItem(DrillResult drillResult)
return item;
}

Dictionary<FileSystemInfo, DrillResult> itemsCache = new();

private void SearchResults_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
{
Expand Down Expand Up @@ -310,12 +310,16 @@ private void copyContainingFolderFullPath(object sender, EventArgs e)
/// </summary>
private void ResetUI()
{
resultsBag.Clear();

// Reset virtual list
// Stop adding more items to the UI
refreshVirtualListTicker.Stop();
refreshVirtualListTicker.Enabled = false;

// Clean results found
resultsBag.Clear();
fileSearchResults.VirtualListSize = 0;

// Clean items cache
itemsCache.Clear();
resultsCountToolStripMenuItem.Text = menuSearchString;
oldResultsCount = -1;
}
Expand Down

0 comments on commit 4abc790

Please sign in to comment.