-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Truffle] Adding Array#shuffle to array.rb. #2676
Conversation
size.times do |i| | ||
r = i + random_generator.rand(size - i).to_int | ||
raise RangeError, "random number too big #{r - i}" if r < 0 || r >= size | ||
swap(@start + i, @start + r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't need to be changed as @tuple.swap
should work fine. We handle that in BodyTranslator
.
@nirvdrum regarding your comments, here is some discussion from jruby channel, does this make sense?
|
This makes sense. We've just been avoiding modifications to the Rubinius source where we can. Since I'm coming into this one late, I'll let @chrisseaton review. |
And not to overly complicate things, but I had a similar issue with jruby/truffle/src/main/ruby/core/shims.rb Lines 204 to 226 in 5a506d2
and passed the String bytes in BodyTranslator: jruby/truffle/src/main/java/org/jruby/truffle/translator/BodyTranslator.java Lines 1593 to 1600 in 5a506d2
That's not to say what I did was right or better, but it's another option. Our notion of |
The extra wrapper might work well for But whatever works for you @bjfish and is clean is good. It's better to try out some different ideas at this stage than it is to work too hard to make everything totally consistent. Can you move to |
@chrisseaton I think I would @nirvdrum would you be able to help in modifying body translator so that @tuple returns a Tuple.class |
The method can still be a member of |
@nirvdrum let me know what you think of the update, I still left the shuffle method modified to use |
My preference is to use |
@nirvdrum Okay, I've updated this to make swap public and use @tuple.swap |
Looks good. If it turns out I'm a moron, we can move this back easily enough :-) |
[Truffle] Adding Array#shuffle to array.rb.
No description provided.