From: David Flanagan Date: 2007-10-15T13:48:53+09:00 Subject: Minor Array.shuffle patch This is a multi-part message in MIME format. --------------030306040309090306090209 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit The attached patch is a small change to the Array.shuffle algorithm to prevent it from attempting to shuffle a 1-element array, and to avoid the final unnecessary swap of the first array element with itself at the end of the shuffle. David --------------030306040309090306090209 Content-Type: text/plain; name="patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch" Index: array.c =================================================================== --- array.c (revision 13705) +++ array.c (working copy) @@ -2874,7 +2874,7 @@ rb_ary_modify(ary); ary_iter_check(ary); - while (i) { + while (i > 1) { long j = genrand_real()*i; VALUE tmp = RARRAY_PTR(ary)[--i]; RARRAY_PTR(ary)[i] = RARRAY_PTR(ary)[j]; --------------030306040309090306090209--