mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
Update sstack.go
This commit is contained in:
parent
2e5cd21edf
commit
20dfef2418
1 changed files with 3 additions and 2 deletions
|
|
@ -52,6 +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])
|
||||||
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)
|
||||||
|
|
@ -62,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(data.(*item[P, V]).value, s.size)
|
s.setIndex(item.value, s.size)
|
||||||
}
|
}
|
||||||
s.active[s.offset] = data.(*item[P, V])
|
s.active[s.offset] = item
|
||||||
s.offset++
|
s.offset++
|
||||||
s.size++
|
s.size++
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue