mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2026-02-25 09:17:32 +00:00
BlockListZoneManager: refactored code for optimization.
This commit is contained in:
@@ -35,6 +35,8 @@ namespace DnsServerCore.Dns.ZoneManagers
|
||||
{
|
||||
#region variables
|
||||
|
||||
readonly static char[] _popWordSeperator = new char[] { ' ', '\t' };
|
||||
|
||||
readonly DnsServer _dnsServer;
|
||||
readonly string _localCacheFolder;
|
||||
|
||||
@@ -87,9 +89,9 @@ namespace DnsServerCore.Dns.ZoneManagers
|
||||
if (line.Length == 0)
|
||||
return line;
|
||||
|
||||
line = line.TrimStart(' ', '\t');
|
||||
line = line.TrimStart(_popWordSeperator);
|
||||
|
||||
int i = line.IndexOfAny(new char[] { ' ', '\t' });
|
||||
int i = line.IndexOfAny(_popWordSeperator);
|
||||
string word;
|
||||
|
||||
if (i < 0)
|
||||
@@ -120,6 +122,7 @@ namespace DnsServerCore.Dns.ZoneManagers
|
||||
{
|
||||
//parse hosts file and populate block zone
|
||||
StreamReader sR = new StreamReader(fS, true);
|
||||
char[] trimSeperator = new char[] { ' ', '\t', '*', '.' };
|
||||
string line;
|
||||
string firstWord;
|
||||
string secondWord;
|
||||
@@ -131,7 +134,7 @@ namespace DnsServerCore.Dns.ZoneManagers
|
||||
if (line == null)
|
||||
break; //eof
|
||||
|
||||
line = line.TrimStart(' ', '\t', '*', '.');
|
||||
line = line.TrimStart(trimSeperator);
|
||||
|
||||
if (line.Length == 0)
|
||||
continue; //skip empty line
|
||||
|
||||
Reference in New Issue
Block a user