Runtime assertions for Ruby literal.fun
ruby
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve performance by reducing ivar reads (#115)

This improves the performance of `_Constraint`, `_Tuple` and `_Union`.

authored by

Joel Drapper and committed by
GitHub
4d44af0c 764b0149

+11 -7
+4 -2
lib/literal/types/constraint_type.rb
··· 10 10 def inspect = "_Constraint(#{inspect_constraints})" 11 11 12 12 def ===(value) 13 - i, len = 0, @object_constraints.size 13 + object_constraints = @object_constraints 14 + 15 + i, len = 0, object_constraints.size 14 16 while i < len 15 - return false unless @object_constraints[i] === value 17 + return false unless object_constraints[i] === value 16 18 i += 1 17 19 end 18 20
+4 -3
lib/literal/types/tuple_type.rb
··· 12 12 13 13 def ===(value) 14 14 return false unless Array === value 15 - return false unless value.size == @types.size 15 + types = @types 16 + return false unless value.size == types.size 16 17 17 - i, len = 0, @types.size 18 + i, len = 0, types.size 18 19 while i < len 19 - return false unless @types[i] === value[i] 20 + return false unless types[i] === value[i] 20 21 i += 1 21 22 end 22 23
+3 -2
lib/literal/types/union_type.rb
··· 15 15 def inspect = "_Union(#{@types.inspect})" 16 16 17 17 def ===(value) 18 - i, len = 0, @types.size 18 + types = @types 19 + i, len = 0, types.size 19 20 while i < len 20 - return true if @types[i] === value 21 + return true if types[i] === value 21 22 i += 1 22 23 end 23 24 end