Update sstack.go

This commit is contained in:
lupin17 2025-12-22 07:18:08 +01:00 committed by GitHub
parent 20dfef2418
commit ab9901b6de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,7 +52,7 @@ func newSstack[P cmp.Ordered, V any](setIndex SetIndexCallback[V]) *sstack[P, V]
// Push a value onto the stack, expanding it if necessary. Required by // Push a value onto the stack, expanding it if necessary. Required by
// heap.Interface. // heap.Interface.
func (s *sstack[P, V]) Push(data any) { func (s *sstack[P, V]) Push(data any) {
item := data.(*item[P, V]) itm := data.(*item[P, V])
if s.size == s.capacity { if s.size == s.capacity {
s.active = make([]*item[P, V], blockSize) s.active = make([]*item[P, V], blockSize)
s.blocks = append(s.blocks, s.active) s.blocks = append(s.blocks, s.active)
@ -63,9 +63,9 @@ func (s *sstack[P, V]) Push(data any) {
s.offset = 0 s.offset = 0
} }
if s.setIndex != nil { if s.setIndex != nil {
s.setIndex(item.value, s.size) s.setIndex(itm.value, s.size)
} }
s.active[s.offset] = item s.active[s.offset] = itm
s.offset++ s.offset++
s.size++ s.size++
} }