mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-18 05:20:50 +00:00
refactor: clarify ReadBytes returns fresh allocation, mode/fname are safe slices
Co-Authored-By: GitHub Copilot <copilot@github.com> Agent-Logs-Url: https://github.com/go-gitea/gitea/sessions/43dab9a5-8c12-41c7-8da6-77c268a65ada Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
4bece1feb4
commit
1d2609a65c
@@ -185,7 +185,9 @@ headerLoop:
|
||||
//
|
||||
// We don't attempt to convert the raw HASH to save a lot of time
|
||||
func ParseCatFileTreeLine(objectFormat ObjectFormat, rd BufferedReader) (mode, fname, sha []byte, n int, err error) {
|
||||
// Read the mode and fname up to and including the NUL separator
|
||||
// Read the mode and fname up to and including the NUL separator.
|
||||
// ReadBytes (unlike ReadSlice) always returns a freshly allocated slice,
|
||||
// so mode and fname can safely reference into it across subsequent reads.
|
||||
readBytes, err := rd.ReadBytes('\x00')
|
||||
if err != nil {
|
||||
return mode, fname, sha, n, err
|
||||
|
||||
Reference in New Issue
Block a user