Skip to content

Commit 31fdb14

Browse files
authored
Reuse slice in SentinelInput of base/context to reduce memory allocation (#466)
1 parent 89ef54d commit 31fdb14

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

api/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (o *EntryOptions) Reset() {
5151
o.batchCount = 1
5252
o.flag = 0
5353
o.slotChain = nil
54-
o.args = nil
54+
o.args = o.args[:0]
5555
o.attachments = nil
5656
}
5757

core/base/context.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ type SentinelInput struct {
9191
func (i *SentinelInput) reset() {
9292
i.BatchCount = 1
9393
i.Flag = 0
94-
if len(i.Args) != 0 {
95-
i.Args = make([]interface{}, 0)
96-
}
94+
i.Args = i.Args[:0]
9795
if len(i.Attachments) != 0 {
9896
i.Attachments = make(map[interface{}]interface{})
9997
}

0 commit comments

Comments
 (0)