summaryrefslogtreecommitdiff
path: root/ext/dl
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dl')
-rw-r--r--ext/dl/lib/dl/struct.rb14
1 files changed, 3 insertions, 11 deletions
diff --git a/ext/dl/lib/dl/struct.rb b/ext/dl/lib/dl/struct.rb
index 27f6b42fd2..23f28bbaa3 100644
--- a/ext/dl/lib/dl/struct.rb
+++ b/ext/dl/lib/dl/struct.rb
@@ -234,17 +234,9 @@ module DL
# DL::TYPE_VOIDP])
# => 8
def CUnionEntity.size(types)
- size = 0
- types.each_with_index{|t,i|
- if( t.is_a?(Array) )
- tsize = PackInfo::SIZE_MAP[t[0]] * t[1]
- else
- tsize = PackInfo::SIZE_MAP[t]
- end
- if( tsize > size )
- size = tsize
- end
- }
+ types.map { |type, count = 1|
+ PackInfo::SIZE_MAP[type] * count
+ }.max
end
# Given +types+, calculate the necessary offset and for each union member