Skip to content

Commit

Permalink
Make performance faster
Browse files Browse the repository at this point in the history
  • Loading branch information
botman99 committed Dec 15, 2024
1 parent 2a40ebf commit 6dd5a33
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ Temporary Items
.vs
bin
obj

.p4config
.p4ignore.txt

Grepy2Help/Debug
Grepy2Help/Release
Grepy2Help/Grepy2Help.chm
4 changes: 2 additions & 2 deletions GetFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public struct WIN32_FIND_DATAW {
private static HandleRef FormHandle;

List<string> filenames;
List<string> folders;
HashSet<string> folders;

public GetFiles(IntPtr InHandle)
{
Expand All @@ -70,7 +70,7 @@ public void Run()
Globals.SearchDirectoryCount = 0;

filenames = new List<string>();
folders = new List<string>();
folders = new HashSet<string>();

filenames = GetFilesForDirectory(Globals.SearchDirectory);

Expand Down
1 change: 1 addition & 0 deletions Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Grepy2.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion Grepy2Help/Grepy2.htm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
</HEAD>
<BODY>
<p style="text-align:right">Previous&nbsp;&nbsp;&nbsp;<A href="WhatIsGrepy.htm">Next</a></p>
<p style="text-align:center">Grepy version 2.4.0</p>
<p style="text-align:center">Grepy version 2.5.0</p>
<br>
<br>
What's New:<br>
<br>
Version 2.5.0 - December 15, 2024<br>
<ul>
<li>Make performance faster.</li>
</ul>
Version 2.4.0 - July 9, 2024<br>
<ul>
<li>Fix a major performance and memory usage issue introduced in 2.3.0 version.</li>
Expand Down
15 changes: 5 additions & 10 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

0 comments on commit 6dd5a33

Please sign in to comment.