vm: simplify (slot).Set code

Refcounter handles nil items just fine.
This commit is contained in:
Roman Khimov 2022-05-17 14:45:08 +03:00
parent f2f66ad36e
commit ae2395f55f

View file

@ -23,13 +23,8 @@ func (s slot) Set(i int, item stackitem.Item, refs *refCounter) {
if s[i] == item {
return
}
old := s[i]
refs.Remove(s[i])
s[i] = item
if old != nil {
refs.Remove(old)
} else {
*refs-- // Not really existing, but counted Null element.
}
refs.Add(item)
}