Skip to content

Commit

Permalink
Made a performance improvement in HtmlToAmpConverter.ConvertFromHtml()
Browse files Browse the repository at this point in the history
  • Loading branch information
ssnenov committed Oct 30, 2016
1 parent 14871d3 commit e51c806
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Html2Amp/HtmlToAmpConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace Html2Amp
{
public class HtmlToAmpConverter
{
private IConfiguration angleSharpConfig { get; set; }
private HtmlParser parser;

private HashSet<ISanitizer> sanitizers { get; set; }
private HashSet<ISanitizer> sanitizers;

private RunConfiguration configuration;

Expand All @@ -28,7 +28,7 @@ public HtmlToAmpConverter()
// We should load the css engine of AngleSharp,
//otherwise it doesn't pasre the css.
// https://github.com/AngleSharp/AngleSharp/issues/90
this.angleSharpConfig = Configuration.Default.WithCss();
this.parser = new HtmlParser(Configuration.Default.WithCss());
this.configuration = new RunConfiguration();
this.sanitizers = new HashSet<ISanitizer>();

Expand Down Expand Up @@ -90,7 +90,7 @@ public ConvertionResult ConvertFromHtml(string htmlSource)
{
Guard.Requires(htmlSource, "htmlSource").IsNotNullOrEmpty();

IHtmlDocument document = new HtmlParser(this.angleSharpConfig).Parse(htmlSource);
IHtmlDocument document = parser.Parse(htmlSource);
IHtmlHtmlElement htmlElement = (IHtmlHtmlElement)document.DocumentElement;

this.EnsureInitilized();
Expand Down

0 comments on commit e51c806

Please sign in to comment.