aboutsummaryrefslogtreecommitdiff
path: root/object
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-02-21 02:07:45 +0800
committerGravatar Runxi Yu2026-02-21 02:07:45 +0800
commit0591334a91e75fb48a081f3130d9633ef0523c5c (patch)
treebcc70622c8aec7ce97f7fdfd8a8563dac5102068 /object
parentobject: Reformat (diff)
signatureNo signature
object: Right, I could use Cut here
Diffstat (limited to 'object')
-rw-r--r--object/ident.go8
-rw-r--r--object/tree.go5
2 files changed, 5 insertions, 8 deletions
diff --git a/object/ident.go b/object/ident.go
index e601802a..432a0977 100644
--- a/object/ident.go
+++ b/object/ident.go
@@ -39,16 +39,16 @@ func ParseIdent(line []byte) (*Ident, error) {
return nil, errors.New("object: ident: missing timestamp separator")
}
rest = rest[1:]
- sp := bytes.IndexByte(rest, ' ')
- if sp < 0 {
+ before, after, ok := bytes.Cut(rest, []byte{' '})
+ if !ok {
return nil, errors.New("object: ident: missing timezone separator")
}
- when, err := strconv.ParseInt(string(rest[:sp]), 10, 64)
+ when, err := strconv.ParseInt(string(before), 10, 64)
if err != nil {
return nil, fmt.Errorf("object: ident: invalid timestamp: %w", err)
}
- tz := rest[sp+1:]
+ tz := after
if len(tz) < 5 {
return nil, errors.New("object: ident: invalid timezone encoding")
}
diff --git a/object/tree.go b/object/tree.go
index b9d1be43..e6a586cb 100644
--- a/object/tree.go
+++ b/object/tree.go
@@ -113,10 +113,7 @@ func TreeEntryNameCompare(entryName []byte, entryMode FileMode, searchName []byt
searchLen++
}
- n := entryLen
- if searchLen < n {
- n = searchLen
- }
+ n := min(searchLen, entryLen)
for i := 0; i < n; i++ {
var ec, sc byte