mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
[PR #410] [MERGED] Optimized RendererBase #1003
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/xoofx/markdig/pull/410
Author: @KrisVandermotten
Created: 3/18/2020
Status: ✅ Merged
Merged: 3/23/2020
Merged by: @xoofx
Base:
master← Head:RendererBase📝 Commits (1)
1f3cf59Optimized RendererBase📊 Changes
1 file changed (+34 additions, -38 deletions)
View changed files
📝
src/Markdig/Renderers/RendererBase.cs(+34 -38)📄 Description
This PR contains a few small optimizations in
RendererBase.It uses some recent C# features, such as pattern matching, to make the code more readable.
It does not changes the semantics of the code. In fact, I believe that the
Write(MarkdownObject obj)method contains abug, and this PR does not attempt to fix it.To understand why there may be a bug here, consider this block of code:
Notice how renderersPerType caches renderers based on the type of the MarkdownObject, whereas the
IMarkdownObjectRenderer.Accept(RendererBase renderer, MarkdownObject obj)method takes an actual MarkdownObject as a parameter, not just its type.The easiest fix would be to change that method signature. Unfortunately, renderers exist that test instance property values in that method, e.g.
NormalizeAutoLinkRenderer.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.