1- using System . Linq ;
21using System . Text ;
32
43namespace ValveKeyValue . Deserialization . KeyValues1
@@ -109,7 +108,7 @@ KVToken ReadComment()
109108 KVToken ReadCondition ( )
110109 {
111110 ReadChar ( ConditionBegin ) ;
112- var text = ReadUntil ( ConditionEnd ) ;
111+ var text = ReadUntil ( static ( c ) => c == ConditionEnd ) ;
113112 ReadChar ( ConditionEnd ) ;
114113
115114 return new KVToken ( KVTokenType . Condition , text ) ;
@@ -118,7 +117,7 @@ KVToken ReadCondition()
118117 KVToken ReadInclusion ( )
119118 {
120119 ReadChar ( InclusionMark ) ;
121- var term = ReadUntil ( new [ ] { ' ' , '\t ' } ) ;
120+ var term = ReadUntil ( static c => c is ' ' or '\t ' ) ;
122121 var value = ReadStringRaw ( ) ;
123122
124123 if ( string . Equals ( term , "include" , StringComparison . Ordinal ) )
@@ -133,12 +132,11 @@ KVToken ReadInclusion()
133132 throw new InvalidDataException ( $ "Unrecognized term after '#' symbol (line { Line } , column { Column } )") ;
134133 }
135134
136- string ReadUntil ( params char [ ] terminators )
135+ string ReadUntil ( Func < int , bool > isTerminator )
137136 {
138137 var escapeNext = false ;
139138
140- var integerTerminators = new HashSet < int > ( terminators . Select ( t => ( int ) t ) ) ;
141- while ( ! integerTerminators . Contains ( Peek ( ) ) || escapeNext )
139+ while ( escapeNext || ! isTerminator ( Peek ( ) ) )
142140 {
143141 var next = Next ( ) ;
144142
@@ -223,7 +221,7 @@ string ReadStringRaw()
223221 string ReadQuotedStringRaw ( )
224222 {
225223 ReadChar ( QuotationMark ) ;
226- var text = ReadUntil ( QuotationMark ) ;
224+ var text = ReadUntil ( static ( c ) => c == QuotationMark ) ;
227225 ReadChar ( QuotationMark ) ;
228226 return text ;
229227 }
0 commit comments