mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 19:05:32 -04:00
Improve instance_size for Tuple
This commit is contained in:
parent
c75c71709f
commit
c5b6a8b5b9
@ -93,7 +93,15 @@ end
|
|||||||
|
|
||||||
struct Tuple(*T)
|
struct Tuple(*T)
|
||||||
def instance_size
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user