From 9f18cbca5b9fd1312ece566c5293e80f135570f6 Mon Sep 17 00:00:00 2001 From: qiufengshe <172344058@qq.com> Date: Tue, 22 Apr 2025 09:28:52 +0800 Subject: [PATCH] minimize temporary strings for better performance (#1224) * minimize temporary strings for better performance * minimize temporary strings for better performance (cherry picked from commit c9e6a8d4c2d7b5fe03ee13af0a79c5334c23b1c0) --- src/Commands/Diff.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 65a2a6f5..8df8cbaa 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text.RegularExpressions; @@ -103,7 +103,7 @@ namespace SourceGit.Commands } else if (line.StartsWith("-size ", StringComparison.Ordinal)) { - _result.LFSDiff.Old.Size = long.Parse(line.Substring(6)); + _result.LFSDiff.Old.Size = long.Parse(line.AsSpan().Slice(6)); } } else if (ch == '+') @@ -114,12 +114,12 @@ namespace SourceGit.Commands } else if (line.StartsWith("+size ", StringComparison.Ordinal)) { - _result.LFSDiff.New.Size = long.Parse(line.Substring(6)); + _result.LFSDiff.New.Size = long.Parse(line.AsSpan().Slice(6)); } } else if (line.StartsWith(" size ", StringComparison.Ordinal)) { - _result.LFSDiff.New.Size = _result.LFSDiff.Old.Size = long.Parse(line.Substring(6)); + _result.LFSDiff.New.Size = _result.LFSDiff.Old.Size = long.Parse(line.AsSpan().Slice(6)); } return; }