Skip to content

Commit

Permalink
improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
yatima1460 committed May 7, 2024
1 parent 43b3117 commit a11587a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
31 changes: 27 additions & 4 deletions Drill/Core/SearchQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal class SearchQueue : IEnumerable<DirectoryInfo>
readonly string searchString;
readonly static string UserName = Environment.UserName;


HashSet<string> visited = [];

static SearchQueue()
Expand Down Expand Up @@ -82,6 +83,18 @@ public void Add(DirectoryInfo item)

public static SearchPriority GetDirectoryPriority(DirectoryInfo sub, string searchString)
{
// all main drives are important besides C:
if (sub.Parent == null)
{
// all folders in C: are generally useless
if (sub.FullName == "C:\\")
return SearchPriority.Low;
return SearchPriority.High;
}




if (
// all hidden folders
sub.Name.StartsWith(".")
Expand All @@ -96,8 +109,6 @@ public static SearchPriority GetDirectoryPriority(DirectoryInfo sub, string sear
|| sub.FullName.ToLower() == "cache"
// often full of garbage
|| sub.FullName.StartsWith($"C:\\Users\\{UserName}\\AppData")
// all folders in C: are generally useless
|| (sub.Parent != null && sub.Parent.FullName == "C:\\")
// If the folder is deep inside an hidden folder
|| sub.FullName.Contains(Path.DirectorySeparatorChar + ".")
)
Expand All @@ -117,8 +128,6 @@ public static SearchPriority GetDirectoryPriority(DirectoryInfo sub, string sear
StringUtils.TokenMatching(searchString, sub.Name)
// user folder
|| sub.FullName == $"C:\\Users\\{UserName}"
// all main drives
|| (sub.Parent == null)
// all folders in the user folder
|| sub.Parent != null && sub.Parent.FullName == $"C:\\Users\\{UserName}"
// english dictionary
Expand All @@ -129,8 +138,22 @@ public static SearchPriority GetDirectoryPriority(DirectoryInfo sub, string sear
return SearchPriority.High;
}

// If folder contains the username it's generally very important
if (sub.Name.ToLower().Contains(UserName.ToLower()))
{
return SearchPriority.High;
}

// If name is long and does not contain spaces or separating characters it's generally something from a tool
if (sub.Name.Length > 16 && !sub.Name.Contains("-") && !sub.Name.Contains(" ") && !sub.Name.Contains("_"))
{
return SearchPriority.High;
}

// Priority is normal if heuristics has no idea what to do
#if DEBUG
// TODO: log here
#endif
return SearchPriority.Normal;
}

Expand Down
10 changes: 9 additions & 1 deletion Drill/Drill.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@
</PropertyGroup>

<PropertyGroup>
<SatelliteResourceLanguages>en-US;en</SatelliteResourceLanguages>
<SatelliteResourceLanguages>en-US;en</SatelliteResourceLanguages>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxPackageSigningEnabled>False</AppxPackageSigningEnabled>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxPackageDir>C:\Users\yatima\Desktop\DrillTest</AppxPackageDir>
<AppxSymbolPackageEnabled>True</AppxSymbolPackageEnabled>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-maccatalyst|AnyCPU'">
Expand Down
4 changes: 4 additions & 0 deletions Drill/Drill.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework>
<UapAppxPackageBuildMode>SideloadOnly</UapAppxPackageBuildMode>
<AppxShowAllApps>False</AppxShowAllApps>
<AppxBuildConfigurationSelection>x64</AppxBuildConfigurationSelection>
<PackageOptionalProjectsInIdeBuilds>False</PackageOptionalProjectsInIdeBuilds>
</PropertyGroup>
</Project>

0 comments on commit a11587a

Please sign in to comment.