diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-05 14:09:15 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-05 14:09:15 +0800 |
commit | 98826d198b228e725ceb5a9fcf1d936ad3817d8e (patch) | |
tree | ba1840795c2b46529128945f80a548f11daf9c00 /git_plumbing.go | |
parent | Reduce allocations when converting string to []byte (diff) | |
download | forge-0.1.22.tar.gz forge-0.1.22.tar.zst forge-0.1.22.zip |
Reduce unnecessary allocations when converting []byte to stringv0.1.22
Diffstat (limited to 'git_plumbing.go')
-rw-r--r-- | git_plumbing.go | 4 |
1 files changed, 2 insertions, 2 deletions
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) { |