mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 05:35:00 +00:00
refactor: use String.AsSpan(int, int)
instead of String.AsSpan().Slice(int, int)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
48bb8e91de
commit
825b74c2a3
12 changed files with 20 additions and 20 deletions
|
@ -205,7 +205,7 @@ namespace SourceGit.Views
|
|||
foreach (var item in selected)
|
||||
{
|
||||
if (item is Models.Commit commit)
|
||||
builder.AppendLine($"{commit.SHA.AsSpan().Slice(0, 10)} - {commit.Subject}");
|
||||
builder.AppendLine($"{commit.SHA.AsSpan(0, 10)} - {commit.Subject}");
|
||||
}
|
||||
|
||||
App.CopyText(builder.ToString());
|
||||
|
|
|
@ -1047,7 +1047,7 @@ namespace SourceGit.Views
|
|||
// The first selected line (partial selection)
|
||||
if (i == startIdx && startPosition.Column > 1)
|
||||
{
|
||||
builder.Append(line.Content.AsSpan().Slice(startPosition.Column - 1));
|
||||
builder.Append(line.Content.AsSpan(startPosition.Column - 1));
|
||||
builder.Append(Environment.NewLine);
|
||||
continue;
|
||||
}
|
||||
|
@ -1064,7 +1064,7 @@ namespace SourceGit.Views
|
|||
{
|
||||
if (endPosition.Column - 1 < line.Content.Length)
|
||||
{
|
||||
builder.Append(line.Content.AsSpan().Slice(0, endPosition.Column - 1));
|
||||
builder.Append(line.Content.AsSpan(0, endPosition.Column - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1254,12 +1254,12 @@ namespace SourceGit.Views
|
|||
var textDiff = DataContext as Models.TextDiff;
|
||||
if (textDiff != null)
|
||||
{
|
||||
var builder = new StringBuilder(512);
|
||||
var builder = new StringBuilder();
|
||||
foreach (var line in textDiff.Lines)
|
||||
{
|
||||
if (line.Content.Length > 10000)
|
||||
{
|
||||
builder.Append(line.Content.AsSpan().Slice(0, 1000));
|
||||
builder.Append(line.Content.AsSpan(0, 1000));
|
||||
builder.Append($"...({line.Content.Length - 1000} character trimmed)");
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue