Skip to content

Commit

Permalink
Merge pull request #332 from njy/patch-1
Browse files Browse the repository at this point in the history
Small perf optimization
  • Loading branch information
JonathanMagnan committed Oct 1, 2019
2 parents 5d0ed87 + d107067 commit 227b51f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/HtmlAgilityPack.Shared/HtmlEntity.cs
Expand Up @@ -3,7 +3,7 @@
// Forum & Issues: https://github.com/zzzprojects/html-agility-pack
// License: https://github.com/zzzprojects/html-agility-pack/blob/master/LICENSE
// More projects: http://www.zzzprojects.com/
// Copyright © ZZZ Projects Inc. 2014 - 2017. All rights reserved.
// Copyright © ZZZ Projects Inc. 2014 - 2017. All rights reserved.

using System;
using System.Collections;
Expand Down Expand Up @@ -788,10 +788,11 @@ public static string Entitize(string text, bool useNames, bool entitizeQuotAmpAn
if ((code > 127) ||
(entitizeQuotAmpAndLtGt && ((code == 34) || (code == 38) || (code == 60) || (code == 62))))
{
string entity;
EntityName.TryGetValue(code, out entity);
string entity = null;
if (useNames)
EntityName.TryGetValue(code, out entity);

if ((entity == null) || (!useNames))
if (entity == null))
{
sb.Append("&#" + code + ";");
}
Expand Down Expand Up @@ -859,4 +860,4 @@ private enum ParseState

#endregion
}
}
}

0 comments on commit 227b51f

Please sign in to comment.