code_review: PR #1402

- it's unnecessary to implement `IEnumerable` interface
- we should check `IsIntersecting` before creating `InlineElement` to avoid unnecessary works suck as running `git cat-file -t <hash>`
- sort whold list after all elements have been added to avoid unnecessary memmove in `Insert`

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-06-08 11:09:20 +08:00
parent fe54d30b70
commit 84fb39f97a
No known key found for this signature in database
7 changed files with 52 additions and 88 deletions

View file

@ -2,8 +2,7 @@
{
public enum InlineElementType
{
None = 0,
Keyword,
Keyword = 0,
Link,
CommitSHA,
Code,
@ -11,10 +10,10 @@
public class InlineElement
{
public InlineElementType Type { get; set; } = InlineElementType.None;
public int Start { get; set; } = 0;
public int Length { get; set; } = 0;
public string Link { get; set; } = "";
public InlineElementType Type { get; }
public int Start { get; }
public int Length { get; }
public string Link { get; }
public InlineElement(InlineElementType type, int start, int length, string link)
{
@ -24,7 +23,7 @@
Link = link;
}
public bool Intersect(int start, int length)
public bool IsIntersecting(int start, int length)
{
if (start == Start)
return true;