Skip to content

Commit

Permalink
ReadStringNullTerminated optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Kermalis committed Sep 8, 2020
1 parent dddb7d2 commit 6975508
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Source/EndianBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,17 @@ public string ReadStringNullTerminated(long offset)
}
public string ReadStringNullTerminated(EncodingType encodingType)
{
string text = "";
do
string text = string.Empty;
while (true)
{
text += ReadChar(encodingType);
char c = ReadChar(encodingType);
if (c == '\0')
{
break;
}
text += c;
}
while (!text.EndsWith("\0", StringComparison.Ordinal));
return text.Remove(text.Length - 1);
return text;
}
public string ReadStringNullTerminated(EncodingType encodingType, long offset)
{
Expand Down

0 comments on commit 6975508

Please sign in to comment.