Fix SubBinary arity
Don't include header size in arity of SubBinary
@@ -277,10 +277,17 @@ impl SubBinary {
}
}
+ /// The size of the non-header fields in bytes
+ const ARITY_IN_BYTES: usize = mem::size_of::<Self>() - mem::size_of::<Term>();
+
+ /// The size of the non-header fields in words
+ fn arity() -> usize {
+ to_word_size(Self::ARITY_IN_BYTES)
+ }
+
#[inline]
fn header() -> Term {
- let arityval = word_size_of::<Self>();
- Term::make_header(arityval, Term::FLAG_SUBBINARY)
+ Term::make_header(arity(), Term::FLAG_SUBBINARY)
}
}
