mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-11 13:54:50 +00:00
[PR #399] [MERGED] Some optimizations in StringLineGroup #996
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/399
Author: @KrisVandermotten
Created: 2/15/2020
Status: ✅ Merged
Merged: 2/18/2020
Merged by: @xoofx
Base:
master← Head:StringLineGroup📝 Commits (1)
7d61df2Some optimizations in StringLineGroup📊 Changes
1 file changed (+17 additions, -29 deletions)
View changed files
📝
src/Markdig/Helpers/StringLineGroup.cs(+17 -29)📄 Description
This PR contributes a few improvements to
StringLineGroup.RemoveAt(int)A memory leak was fixed and code duplication reduced.
ToSlice(List<LineOffset>)First, the case where
Count == 1has been moved before the case whereCount == 0, simply because it is so much more common. Indeed, out of 1023 unit tests that call this method, 872 execute theCount == 1branch, but none of them execute theCount == 0branch.Secondly, the loop was restructured to simplify it and reduce code duplication. Using
ref var line = ref Lines[i];, theLinesarray is indexed only once per iteration.Iterator.NextChar()_offset++;has been moved into theifbranch, so that the_offset--;in the else branch can be removed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.