Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small perf optimization #332

Merged
merged 1 commit into from Oct 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}
}
}