mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
perf: minimize temporary strings for better performance (#1255)
This commit is contained in:
parent
53a55467f1
commit
48bb8e91de
8 changed files with 35 additions and 23 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
@ -147,9 +148,9 @@ namespace SourceGit.Models
|
|||
public void GenerateNewPatchFromSelection(Change change, string fileBlobGuid, TextDiffSelection selection, bool revert, string output)
|
||||
{
|
||||
var isTracked = !string.IsNullOrEmpty(fileBlobGuid);
|
||||
var fileGuid = isTracked ? fileBlobGuid.Substring(0, 8) : "00000000";
|
||||
var fileGuid = isTracked ? fileBlobGuid.AsSpan().Slice(0, 8) : "00000000".AsSpan();
|
||||
|
||||
var builder = new StringBuilder();
|
||||
var builder = new StringBuilder(512);
|
||||
builder.Append("diff --git a/").Append(change.Path).Append(" b/").Append(change.Path).Append('\n');
|
||||
if (!revert && !isTracked)
|
||||
builder.Append("new file mode 100644\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue