From 98826d198b228e725ceb5a9fcf1d936ad3817d8e Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 5 Apr 2025 14:09:15 +0800 Subject: Reduce unnecessary allocations when converting []byte to string --- git_plumbing.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git_plumbing.go') diff --git a/git_plumbing.go b/git_plumbing.go index e787c59..15329ad 100644 --- a/git_plumbing.go +++ b/git_plumbing.go @@ -76,14 +76,14 @@ func buildTreeRecursive(ctx context.Context, repoPath, baseTree string, updates if modeEnd < 0 { return errors.New("invalid tree format") } - mode := string(data[i : i+modeEnd]) + mode := bytesToString(data[i : i+modeEnd]) i += modeEnd + 1 nameEnd := bytes.IndexByte(data[i:], 0) if nameEnd < 0 { return errors.New("missing null after filename") } - name := string(data[i : i+nameEnd]) + name := bytesToString(data[i : i+nameEnd]) i += nameEnd + 1 if i+20 > len(data) { -- cgit v1.2.3