BlockListZoneManager: refactored code for optimization.

This commit is contained in:
Shreyas Zare
2023-02-05 16:29:37 +05:30
parent cb5cd38ef8
commit 975bc5d584

View File

@@ -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