Skip to content

Commit 7b11e8e

Browse files
committed
Remove async, rule loading speed ~x2, pragmas for optimal perf
Rule loading is roughly twice as fast over the previous version thanks to prepared statements. Removed async functions. Add pragmas for optimal performance. Add new indexes for optimal performance.
1 parent 566921a commit 7b11e8e

File tree

8 files changed

+208
-180
lines changed

8 files changed

+208
-180
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,6 @@ paket-files/
253253
# JetBrains Rider
254254
.idea/
255255
*.sln.iml
256+
257+
# Coverity
258+
**/cov-int/

DistillNET/DistillNET/DistillNET.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
<RepositoryUrl>https://github.com/TechnikEmpire/DistillNET</RepositoryUrl>
1010
<Description>DistillNET is a library for matching and filtering HTTP requests URLs using the Adblock Plus Filter format.</Description>
1111
<Copyright>Copyright © 2017 - 2018 Jesse Nicholson</Copyright>
12-
<Version>1.5.0</Version>
12+
<Version>1.5.1</Version>
1313
<Authors>Jesse Nicholson</Authors>
1414
<Company>Technik Empire</Company>
1515
<PackageTags>DistillNET Adblock AdblockPlus Adblock-Plus URL-Filter URL-Filtering Content-Filter Filter</PackageTags>
16-
<PackageReleaseNotes>Version fix. Bump minor because of configurable feature addition.</PackageReleaseNotes>
17-
<AssemblyVersion>1.5.0.0</AssemblyVersion>
16+
<PackageReleaseNotes>Rule loading is ~twice as fast as previous version now thanks to prepared statements.</PackageReleaseNotes>
17+
<AssemblyVersion>1.5.1.0</AssemblyVersion>
1818
</PropertyGroup>
1919

2020
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
@@ -26,8 +26,8 @@
2626
</PropertyGroup>
2727

2828
<ItemGroup>
29-
<PackageReference Include="Microsoft.Data.SQLite" Version="2.0.1" />
30-
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.1" />
29+
<PackageReference Include="Microsoft.Data.SQLite" Version="2.1.0-rc1-final" />
30+
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.2" />
3131
</ItemGroup>
3232

3333
</Project>

DistillNET/DistillNET/DistillNET/AbpFormatRuleParser.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public class AbpFormatRuleParser
2020
/// <summary>
2121
/// Delimiters used for splitting URL filtering options.
2222
/// </summary>
23-
private static char[] s_optionsDelim = new[] { ',' };
23+
private static readonly char[] s_optionsDelim = new[] { ',' };
2424

2525
/// <summary>
2626
/// Delimiters used for splitting domains specified in the URL filtering options "domains".
2727
/// </summary>
28-
private static char[] s_domainsDelim = new[] { '|' };
28+
private static readonly char[] s_domainsDelim = new[] { '|' };
2929

3030
internal class OptionsDictComparer : IEqualityComparer<string>
3131
{
@@ -368,13 +368,14 @@ private Filter ParseUrlFilter(string rule, int optionsStartOffset, bool hasOptio
368368
}
369369
}
370370
}
371+
371372
#endif
372373

374+
373375
// Parse out the rest of the options.
374-
UrlFilter.UrlFilterOptions asOpt;
375-
foreach(var opt in allOptions)
376-
{
377-
if(s_optionsMap.TryGetValue(opt, out asOpt))
376+
foreach (var opt in allOptions)
377+
{
378+
if (s_optionsMap.TryGetValue(opt, out UrlFilter.UrlFilterOptions asOpt))
378379
{
379380
enumOptions |= asOpt;
380381
enumOptions &= ~UrlFilter.UrlFilterOptions.None;
@@ -466,8 +467,7 @@ private Filter ParseUrlFilter(string rule, int optionsStartOffset, bool hasOptio
466467
break;
467468
}
468469

469-
Uri parsedUri = null;
470-
if(Uri.TryCreate(anchoredAddress, UriKind.Absolute, out parsedUri))
470+
if (Uri.TryCreate(anchoredAddress, UriKind.Absolute, out Uri parsedUri))
471471
{
472472
applicableDomains.Add(parsedUri.Host);
473473
}

0 commit comments

Comments
 (0)