Date: Tue, 04 Sep 2001 11:37:07 +0100 From: Jasper McCrea Subject: Re: references, slices, voodoo Message-Id: <3B94AED2.698A3CF@guideguide.com> Walter Hafner wrote: > > What I don't understand: > > abigail writes: > > > Note that the stupid 'unless $i == $j' no longer appears in modern > > editions of the FAQ. > > why "stupid"? > > -Walter I suppose because the test isn't much faster than the swap. Quick benchmark showed that a swap was only 1/5 as fast as the test, so if the array has more than twice as many elements that are different than are the same (likely), it's a waste of time to do the test every time, when you may as well swap. A nice XOR swap benchmarked 1/2 as fast as a (==) test, but I suppose it's harder to see what's going on there, so more confusion would arise. Jasper -- split//,'019617511192'. '17011111610114101114'. '21011141011840799901'. '17101174'; foreach(0.. # my $#_){$_[$_ # signature is too ++]^=$_[$_ # bignature --]^=$_[$_ ]^=$_[++ $_]if!($_% 2)}$g.=$_ ,chr($g)=~ /(\w)/&&($o.=$1and $g='')foreach@_; print"$o\n"