Skip to content

Commit 73cfc03

Browse files
committed
Use SearchValues
1 parent ed013e8 commit 73cfc03

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

ValveKeyValue/ValveKeyValue/Deserialization/KeyValues3/KV3TokenReader.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Linq;
1+
using System.Buffers;
22
using System.Text;
33
using ValveKeyValue.KeyValues3;
44
using Encoding = ValveKeyValue.KeyValues3.Encoding;
@@ -16,15 +16,13 @@ class KV3TokenReader : KVTokenReader
1616
const char Assignment = '=';
1717
const char Comma = ',';
1818

19+
// Dota 2 binary from 2017 used "+" as a terminate (for flagged values), but then they changed it to "|"
20+
static readonly SearchValues<char> TokenTerminators = SearchValues.Create("{}[]=, \t\n\r'\":|;");
21+
1922
public KV3TokenReader(TextReader textReader) : base(textReader)
2023
{
21-
// Dota 2 binary from 2017 used "+" as a terminate (for flagged values), but then they changed it to "|"
22-
var terminators = "{}[]=, \t\n\r'\":|;".ToCharArray();
23-
integerTerminators = new HashSet<int>(terminators.Select(t => (int)t));
2424
}
2525

26-
readonly HashSet<int> integerTerminators;
27-
2826
public KVToken ReadNextToken()
2927
{
3028
ObjectDisposedException.ThrowIf(disposed, this);
@@ -315,7 +313,7 @@ string ReadToken()
315313
{
316314
next = Peek();
317315

318-
if (next <= ' ' || integerTerminators.Contains(next))
316+
if (next <= ' ' || TokenTerminators.Contains((char)next))
319317
{
320318
break;
321319
}

0 commit comments

Comments
 (0)