From b78f6b0ea8da7aa857aa27326f683d7995ebcf7a Mon Sep 17 00:00:00 2001 From: qiufengshe <172344058@qq.com> Date: Sun, 18 May 2025 20:52:05 +0800 Subject: [PATCH] perf: minimize temporary strings for better performance (#1332) --- src/ViewModels/Histories.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index 555954d9..f21d2636 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.IO; @@ -387,7 +387,7 @@ namespace SourceGit.ViewModels { var builder = new StringBuilder(); foreach (var c in selected) - builder.AppendLine($"{c.SHA.Substring(0, 10)} - {c.Subject}"); + builder.AppendLine($"{c.SHA.AsSpan(0, 10)} - {c.Subject}"); App.CopyText(builder.ToString()); e.Handled = true; @@ -780,7 +780,7 @@ namespace SourceGit.ViewModels copyInfo.Icon = App.CreateMenuIcon("Icons.Info"); copyInfo.Click += (_, e) => { - App.CopyText($"{commit.SHA.Substring(0, 10)} - {commit.Subject}"); + App.CopyText($"{commit.SHA.AsSpan(0, 10)} - {commit.Subject}"); e.Handled = true; };