Speedier unmapped folders lookup.

This commit is contained in:
Mark McDowall
2013-08-20 18:17:06 -07:00
parent f9437baf80
commit 0c2a1c60b1
5 changed files with 41 additions and 18 deletions
+1
View File
@@ -91,6 +91,7 @@
<Compile Include="Exceptions\NzbDroneException.cs" />
<Compile Include="Instrumentation\GlobalExceptionHandlers.cs" />
<Compile Include="Instrumentation\ExceptronTarget.cs" />
<Compile Include="PathEqualityComparer.cs" />
<Compile Include="TPL\LimitedConcurrencyLevelTaskScheduler.cs" />
<Compile Include="Security\IgnoreCertErrorPolicy.cs" />
<Compile Include="StringExtensions.cs" />
+20
View File
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Common
{
public class PathEqualityComparer : IEqualityComparer<String>
{
public bool Equals(string x, string y)
{
return x.PathEquals(y);
}
public int GetHashCode(string obj)
{
return obj.CleanFilePath().GetHashCode();
}
}
}
+4 -3
View File
@@ -35,11 +35,12 @@ namespace NzbDrone.Common
return info.FullName.TrimEnd('/').Trim('\\', ' ');
}
public static bool PathEquals(this string firstPath, string secondPath)
{
Ensure.That(() => firstPath).IsValidPath();
Ensure.That(() => secondPath).IsValidPath();
if (OsInfo.IsLinux)
{
return String.Equals(firstPath.CleanFilePath(), secondPath.CleanFilePath());
}
return String.Equals(firstPath.CleanFilePath(), secondPath.CleanFilePath(), StringComparison.InvariantCultureIgnoreCase);
}