Skip to content

Commit

Permalink
Don't count non-ascii chars into maxChar limit in CharacterMap
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan committed Apr 7, 2020
1 parent 256b4d3 commit 215f850
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Markdig/Helpers/CharacterMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,22 @@ public CharacterMap(IEnumerable<KeyValuePair<char, T>> maps)
{
var openingChar = map.Key;
charSet.Add(openingChar);
maxChar = Math.Max(maxChar, openingChar);

if (openingChar < 128)
{
maxChar = Math.Max(maxChar, openingChar);
}
else
{
nonAsciiMap ??= new Dictionary<uint, T>();
}
}

OpeningCharacters = charSet.ToArray();
Array.Sort(OpeningCharacters);

asciiMap = new T[maxChar + 1];

if (maxChar >= 128)
nonAsciiMap = new Dictionary<uint, T>();

foreach (var state in maps)
{
char openingChar = state.Key;
Expand Down

0 comments on commit 215f850

Please sign in to comment.