vm: do not store items of scalar types in map
As they do not contain any other items, they can be only accounted via total size.
This commit is contained in:
parent
735b937608
commit
f957af35d4
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) {
|
||||
*s.size++
|
||||
|
||||
s.itemCount[item]++
|
||||
if s.itemCount[item] > 1 {
|
||||
switch item.(type) {
|
||||
case *ArrayItem, *StructItem, *MapItem:
|
||||
if s.itemCount[item]++; s.itemCount[item] > 1 {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -229,11 +230,14 @@ func (s *Stack) updateSizeAdd(item StackItem) {
|
|||
s.updateSizeAdd(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Stack) updateSizeRemove(item StackItem) {
|
||||
*s.size--
|
||||
|
||||
switch item.(type) {
|
||||
case *ArrayItem, *StructItem, *MapItem:
|
||||
if s.itemCount[item] > 1 {
|
||||
s.itemCount[item]--
|
||||
return
|
||||
|
@ -251,6 +255,7 @@ func (s *Stack) updateSizeRemove(item StackItem) {
|
|||
s.updateSizeRemove(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// InsertAt inserts the given item (n) deep on the stack.
|
||||
|
|
Loading…
Reference in a new issue