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

@ -638,6 +638,8 @@ namespace SourceGit.ViewModels
var start = match.Index;
var len = match.Length;
if (inlines.Intersect(start, len) != null)
continue;
var url = message.Substring(start, len);
if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
@ -653,6 +655,8 @@ namespace SourceGit.ViewModels
var start = match.Index;
var len = match.Length;
if (inlines.Intersect(start, len) != null)
continue;
var sha = match.Groups[1].Value;
var isCommitSHA = new Commands.IsCommitSHA(_repo.FullPath, sha).Result();
@ -660,6 +664,7 @@ namespace SourceGit.ViewModels
inlines.Add(new Models.InlineElement(Models.InlineElementType.CommitSHA, start, len, sha));
}
inlines.Sort();
return inlines;
}