Permalink
Browse files

better implementation for make_tuple (avoids dispatch and creating an…

… array)
  • Loading branch information...
1 parent 90f108e commit 84641c5d54a88dba576258ebd1116d2c2c78894e @rkh committed Jan 26, 2011
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/convinius/generator.rb
View
@@ -3,10 +3,16 @@ module Generator
append_features Rubinius::Generator
def make_tuple(count)
- push_rubinius
- find_const :Tuple
- move_down count
- send :[], count
+ push count
+ invoke_primitive :tuple_allocate, 1
+ (count - 1).downto(0) do |i|
+ dup
+ rotate 3
+ push i
+ swap
+ invoke_primitive :tuple_put, 3
+ pop
+ end
end
end
end

0 comments on commit 84641c5

Please sign in to comment.