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:
CPerezz 2026-04-19 22:15:48 +02:00
parent c08048eb84
commit d216942b7c
No known key found for this signature in database
GPG key ID: 62045F34B97177DD

View file

@ -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 }