Improve instance_size for Tuple

This commit is contained in:
Alex Ling 2021-09-05 13:57:20 +00:00
parent c75c71709f
commit c5b6a8b5b9

View File

@ -93,7 +93,15 @@ end
struct Tuple(*T)
def instance_size
sizeof(T) # iterate T and add instance_size of that
sizeof(T) + # total size of non-reference types
self.sum do |e|
next 0 unless e.is_a? Reference
if e.responds_to? :instance_size
e.instance_size
else
instance_sizeof(typeof(e))
end
end
end
end