From 6dd5a33c76db96eafbde28003cf4ee5abd171538 Mon Sep 17 00:00:00 2001 From: Jeff Broome Date: Sun, 15 Dec 2024 09:35:28 -0600 Subject: [PATCH] Make performance faster --- .gitignore | 7 +++++++ GetFiles.cs | 4 ++-- Globals.cs | 1 + Grepy2.nsi | 2 +- Grepy2Help/Grepy2.htm | 6 +++++- MainForm.cs | 15 +++++---------- Properties/AssemblyInfo.cs | 4 ++-- 7 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 1fe7968..dfe9b47 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,10 @@ Temporary Items .vs bin obj + +.p4config +.p4ignore.txt + +Grepy2Help/Debug +Grepy2Help/Release +Grepy2Help/Grepy2Help.chm diff --git a/GetFiles.cs b/GetFiles.cs index 60aebd0..d6beeb3 100644 --- a/GetFiles.cs +++ b/GetFiles.cs @@ -46,7 +46,7 @@ public struct WIN32_FIND_DATAW { private static HandleRef FormHandle; List filenames; - List folders; + HashSet folders; public GetFiles(IntPtr InHandle) { @@ -70,7 +70,7 @@ public void Run() Globals.SearchDirectoryCount = 0; filenames = new List(); - folders = new List(); + folders = new HashSet(); filenames = GetFilesForDirectory(Globals.SearchDirectory); diff --git a/Globals.cs b/Globals.cs index 385fb97..9adc710 100644 --- a/Globals.cs +++ b/Globals.cs @@ -83,6 +83,7 @@ public enum SearchFileStatus public static SearchFile[] SearchFiles; public static int SearchDirectoryCount; // number of directories we searched through to collect files to search + public static int NumFilesSearched; public static bool bIsGrepyReadOnly = false; diff --git a/Grepy2.nsi b/Grepy2.nsi index 5a42d72..6eb08d1 100644 --- a/Grepy2.nsi +++ b/Grepy2.nsi @@ -8,7 +8,7 @@ ; The name of the installer Name "Grepy2" -!define VERSION '2.4.0' +!define VERSION '2.5.0' ; The file to write OutFile "Grepy2-${VERSION}.exe" diff --git a/Grepy2Help/Grepy2.htm b/Grepy2Help/Grepy2.htm index f568ee4..63efda7 100644 --- a/Grepy2Help/Grepy2.htm +++ b/Grepy2Help/Grepy2.htm @@ -6,11 +6,15 @@

Previous   Next

-

Grepy version 2.4.0

+

Grepy version 2.5.0



What's New:

+Version 2.5.0 - December 15, 2024
+
    +
  • Make performance faster.
  • +
Version 2.4.0 - July 9, 2024
  • Fix a major performance and memory usage issue introduced in 2.3.0 version.
  • diff --git a/MainForm.cs b/MainForm.cs index d928705..aec5487 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -258,6 +258,8 @@ protected override void WndProc(ref Message m) Globals.bShouldStopWorkerJobs = false; + Globals.NumFilesSearched = 0; + for( int i = 0; i < NumWorkersToStart; i++ ) { Globals.Workers[i].SearchFilesIndex = NextSearchFileJobIndex; @@ -317,16 +319,9 @@ protected override void WndProc(ref Message m) if( bIsSearchInProgress ) { - int num_searched = 0; - for( int i = 0; i < Globals.SearchFiles.Length; i++ ) - { - if( (Globals.SearchFiles[i] != null) && (Globals.SearchFiles[i].Status != Globals.SearchFileStatus.NotProcessed) ) - { - num_searched++; - } - } + Globals.NumFilesSearched++; - SearchingProgressBar.Value = (num_searched * 100) / Globals.SearchFiles.Length; + SearchingProgressBar.Value = (Globals.NumFilesSearched * 100) / Globals.SearchFiles.Length; // We want to add the files to the ListView in the sorted order that they appear in the SearchFiles array. // Workers will complete files at different rates, so we add files to the ListView once that file's index @@ -371,7 +366,7 @@ protected override void WndProc(ref Message m) LowestWorkerFileProcessedIndex++; } - if( num_searched == Globals.SearchFiles.Length ) + if( Globals.NumFilesSearched == Globals.SearchFiles.Length ) { // we are done searching through files stopSearchToolStripMenuItem.Visible = false; diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 25bd631..92db2ff 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.4.0.0")] -[assembly: AssemblyFileVersion("2.4.0.0")] +[assembly: AssemblyVersion("2.5.0.0")] +[assembly: AssemblyFileVersion("2.5.0.0")]