On Wed, 3 Apr 2002, Sean M. Burke wrote: > while(1) { > $j = int rand($i-- || return); > $t = $deck->[$i]; > $deck->[$i] = $deck->[$j]; > $deck->[$j] = $t; > } > # Thanks to Silmaril for pointing out that the temp var is faster
I won't argue with benchmarks, but if this is indeed faster than the equivalent list assignment, it means there's a serious need for some optimization somewhere in the list assignment code. (It's been a long while since I looked there, and I'm not going to dive in now, but IIRC assignments where the left and right hand sides overlap are handled as special cases. It may be that this special handling has been implemented in a suboptimal way. Or maybe it's just overhead from the generic list assignment code as compared to scalar assignment.) -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "I'd say the number of people in the world who really understand Perl's regex code is about three, plus or minus four." -- Larry Wall on the perl5-porters list