Merge pull request #559 from nspcc-dev/feature/stack_limits
vm: don't refcount simple items Improves 1.4M to 1.5M 100K mainnet block import test by ~4%.
This commit is contained in:
commit
33958be45f
1 changed files with 31 additions and 26 deletions
|
@ -214,8 +214,9 @@ func (s *Stack) insert(e, at *Element) *Element {
|
||||||
func (s *Stack) updateSizeAdd(item StackItem) {
|
func (s *Stack) updateSizeAdd(item StackItem) {
|
||||||
*s.size++
|
*s.size++
|
||||||
|
|
||||||
s.itemCount[item]++
|
switch item.(type) {
|
||||||
if s.itemCount[item] > 1 {
|
case *ArrayItem, *StructItem, *MapItem:
|
||||||
|
if s.itemCount[item]++; s.itemCount[item] > 1 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,11 +230,14 @@ func (s *Stack) updateSizeAdd(item StackItem) {
|
||||||
s.updateSizeAdd(v)
|
s.updateSizeAdd(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stack) updateSizeRemove(item StackItem) {
|
func (s *Stack) updateSizeRemove(item StackItem) {
|
||||||
*s.size--
|
*s.size--
|
||||||
|
|
||||||
|
switch item.(type) {
|
||||||
|
case *ArrayItem, *StructItem, *MapItem:
|
||||||
if s.itemCount[item] > 1 {
|
if s.itemCount[item] > 1 {
|
||||||
s.itemCount[item]--
|
s.itemCount[item]--
|
||||||
return
|
return
|
||||||
|
@ -251,6 +255,7 @@ func (s *Stack) updateSizeRemove(item StackItem) {
|
||||||
s.updateSizeRemove(v)
|
s.updateSizeRemove(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// InsertAt inserts the given item (n) deep on the stack.
|
// InsertAt inserts the given item (n) deep on the stack.
|
||||||
|
|
Loading…
Reference in a new issue