code_review: PR #1292

Use syntax `String.AsSpan(int start, int len)` instead of `String.AsSpan().Slice(int start, int len)`

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-05-09 09:30:00 +08:00
parent 15ee2dac91
commit e8bf58f6c3
No known key found for this signature in database
3 changed files with 8 additions and 8 deletions

View file

@ -24,7 +24,7 @@ namespace SourceGit.Models
{
var trimmedUrl = url.AsSpan();
if (url.EndsWith(".git"))
trimmedUrl = url.AsSpan().Slice(0, url.Length - 4);
trimmedUrl = url.AsSpan(0, url.Length - 4);
if (url.StartsWith("https://github.com/", StringComparison.Ordinal))
outs.Add(new($"Github ({trimmedUrl.Slice(19)})", $"{url}/commit/"));

View file

@ -344,28 +344,28 @@ namespace SourceGit.Models
if (filter.Mode == FilterMode.Included)
includedRefs.Add(filter.Pattern);
else if (filter.Mode == FilterMode.Excluded)
excludedBranches.Add($"--exclude=\"{filter.Pattern.AsSpan().Slice(11)}\" --decorate-refs-exclude=\"{filter.Pattern}\"");
excludedBranches.Add($"--exclude=\"{filter.Pattern.AsSpan(11)}\" --decorate-refs-exclude=\"{filter.Pattern}\"");
}
else if (filter.Type == FilterType.LocalBranchFolder)
{
if (filter.Mode == FilterMode.Included)
includedRefs.Add($"--branches={filter.Pattern.AsSpan().Slice(11)}/*");
includedRefs.Add($"--branches={filter.Pattern.AsSpan(11)}/*");
else if (filter.Mode == FilterMode.Excluded)
excludedBranches.Add($"--exclude=\"{filter.Pattern.AsSpan().Slice(11)}/*\" --decorate-refs-exclude=\"{filter.Pattern}/*\"");
excludedBranches.Add($"--exclude=\"{filter.Pattern.AsSpan(11)}/*\" --decorate-refs-exclude=\"{filter.Pattern}/*\"");
}
else if (filter.Type == FilterType.RemoteBranch)
{
if (filter.Mode == FilterMode.Included)
includedRefs.Add(filter.Pattern);
else if (filter.Mode == FilterMode.Excluded)
excludedRemotes.Add($"--exclude=\"{filter.Pattern.AsSpan().Slice(13)}\" --decorate-refs-exclude=\"{filter.Pattern}\"");
excludedRemotes.Add($"--exclude=\"{filter.Pattern.AsSpan(13)}\" --decorate-refs-exclude=\"{filter.Pattern}\"");
}
else if (filter.Type == FilterType.RemoteBranchFolder)
{
if (filter.Mode == FilterMode.Included)
includedRefs.Add($"--remotes={filter.Pattern.AsSpan().Slice(13)}/*");
includedRefs.Add($"--remotes={filter.Pattern.AsSpan(13)}/*");
else if (filter.Mode == FilterMode.Excluded)
excludedRemotes.Add($"--exclude=\"{filter.Pattern.AsSpan().Slice(13)}/*\" --decorate-refs-exclude=\"{filter.Pattern}/*\"");
excludedRemotes.Add($"--exclude=\"{filter.Pattern.AsSpan(13)}/*\" --decorate-refs-exclude=\"{filter.Pattern}/*\"");
}
else if (filter.Type == FilterType.Tag)
{