mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
[PR #410] Optimized RendererBase #1008
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?
Original Pull Request: https://github.com/xoofx/markdig/pull/410
State: closed
Merged: Yes
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.