Use bytesize and add comments

This commit is contained in:
Leeingnyo 2021-09-03 11:11:28 +09:00
parent 365f71cd1d
commit 0a8fd993e5

View File

@ -171,8 +171,10 @@ private class SortedEntriesCacheEntry
end
def instance_size
@value.size * (instance_sizeof(String) + sizeof(String)) +
@value.sum(&.size) + instance_sizeof(SortedEntriesCacheEntry)
instance_sizeof(SortedEntriesCacheEntry) + # sizeof itself
instance_sizeof(String) + @key.bytesize + # allocated memory for @key
@value.size * (instance_sizeof(String) + sizeof(String)) +
@value.sum(&.bytesize) # elements in Array(String)
end
end