mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 09:51:36 +00:00
trie/bintrie: make IsEmpty kind-based
Comparing against emptyRef (the single value makeRef(kindEmpty, 0)) only works because no other nodeRef with kindEmpty is ever constructed. That invariant is easy to break if future code ever produces a kindEmpty ref with nonzero index. Test the kind directly so any kindEmpty ref reads as empty regardless of index.
This commit is contained in:
parent
c08048eb84
commit
d216942b7c
1 changed files with 1 additions and 1 deletions
|
|
@ -53,4 +53,4 @@ func (r nodeRef) Kind() nodeKind { return nodeKind(uint32(r) >> kindShift) }
|
|||
// Index within the typed pool.
|
||||
func (r nodeRef) Index() uint32 { return uint32(r) & indexMask }
|
||||
|
||||
func (r nodeRef) IsEmpty() bool { return r == emptyRef }
|
||||
func (r nodeRef) IsEmpty() bool { return r.Kind() == kindEmpty }
|
||||
|
|
|
|||
Loading…
Reference in a new issue