44using System ;
55using System . IO ;
66using System . Text ;
7- using System . Collections . Generic ;
87
98namespace SharpConfig
109{
@@ -26,7 +25,6 @@ private static void Parse(StringReader reader, Configuration config)
2625 {
2726 var currentSection = new Section ( Section . DefaultSectionName ) ;
2827 var preCommentBuilder = new StringBuilder ( ) ;
29- HashSet < char > validCommentChars = new HashSet < char > ( Configuration . ValidCommentChars ) ; // Initialize once for each reader to optimize performance
3028 var lineNumber = 0 ;
3129 string line ;
3230
@@ -44,7 +42,7 @@ private static void Parse(StringReader reader, Configuration config)
4442 continue ;
4543 }
4644
47- var comment = ParseComment ( line , validCommentChars , out int commentIndex ) ;
45+ var comment = ParseComment ( line , out int commentIndex ) ;
4846
4947 if ( commentIndex == 0 )
5048 {
@@ -111,7 +109,7 @@ private static void Parse(StringReader reader, Configuration config)
111109 }
112110 }
113111
114- private static string ParseComment ( string line , HashSet < char > validCommentChars , out int commentCharIndex )
112+ private static string ParseComment ( string line , out int commentCharIndex )
115113 {
116114 // A comment starts with a valid comment character that:
117115 // 1. is not within a quote (eg. "this is # not a comment"), and
@@ -130,7 +128,7 @@ private static string ParseComment(string line, HashSet<char> validCommentChars,
130128 while ( index < length ) // traverse line from left to right
131129 {
132130 var currentChar = line [ index ] ;
133- var isValidCommentChar = validCommentChars . Contains ( currentChar ) ;
131+ var isValidCommentChar = Configuration . ValidCommentChars . Contains ( currentChar ) ;
134132 var isQuotationMark = currentChar == '\" ' ;
135133 var isCharWithinQuotes = ( quoteCount & 1 ) == 1 ; // bitwise AND is slightly faster
136134 var isCharEscaped = index > 0 && line [ index - 1 ] == '\\ ' ;
0 commit comments