From: Peter Rabbitson Date: Mon, 16 Jun 2014 14:37:27 +0000 (+0200) Subject: Minor optimization of codepath (no func changes) X-Git-Tag: v0.082800~168 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e6ed824bbb02cbe1dfdc18987f468791af228e63;p=dbsrgits%2FDBIx-Class.git Minor optimization of codepath (no func changes) --- diff --git a/lib/DBIx/Class/Ordered.pm b/lib/DBIx/Class/Ordered.pm index a5db68b..539abd8 100644 --- a/lib/DBIx/Class/Ordered.pm +++ b/lib/DBIx/Class/Ordered.pm @@ -742,20 +742,13 @@ sub _shift_siblings { if ( first { $_ eq $position_column } ( map { @$_ } (values %{{ $rsrc->unique_constraints }} ) ) ) { - my $cursor = $shift_rs->search ( + my $clean_rs = $rsrc->resultset; + + for ( $shift_rs->search ( {}, { order_by => { "-$ord", $position_column }, select => [$position_column, @pcols] } - )->cursor; - my $rs = $rsrc->resultset; - - my @all_data = $cursor->all; - while (my $data = shift @all_data) { - my $pos = shift @$data; - my $cond; - for my $i (0.. $#pcols) { - $cond->{$pcols[$i]} = $data->[$i]; - } - - $rs->find($cond)->update ({ $position_column => $pos + ( ($op eq '+') ? 1 : -1 ) }); + )->cursor->all ) { + my $pos = shift @$_; + $clean_rs->find(@$_)->update ({ $position_column => $pos + ( ($op eq '+') ? 1 : -1 ) }); } } else {