Skip to content

Commit

Permalink
not do xchg if no-op
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Feb 12, 2024
1 parent 86891d1 commit dddc2eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Basic/Core/Basic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ sub PDL::rvals { # Return radial distance from given point and offset
for ($i=0; $i<$r->getndims; $i++) {
$offset = (defined $pos[$i] ? $pos[$i] : int($r->getdim($i)/2));
# Note careful coding for speed and min memory footprint
PDL::Primitive::axisvalues($tmp->xchg(0,$i)->inplace);
PDL::Primitive::axisvalues((0==$i?$tmp:$tmp->xchg(0,$i))->inplace);
$tmp -= $offset; $tmp *= $tmp;
$r += $tmp;
}
Expand Down Expand Up @@ -633,7 +633,7 @@ sub PDL::axisvals {
$dummy .= 0;
return $dummy;
}
my $bar = $dummy->xchg(0,$nth);
my $bar = 0==$nth ? $dummy : $dummy->xchg(0,$nth);
PDL::Primitive::axisvalues($bar->inplace);
return $dummy;
}
Expand All @@ -648,7 +648,7 @@ sub axisvals2 {
$dummy .= 0;
return $dummy;
}
my $bar = $dummy->xchg(0,$nth);
my $bar = 0==$nth ? $dummy : $dummy->xchg(0,$nth);
PDL::Primitive::axisvalues($bar->inplace);
return $dummy;
}
Expand Down
6 changes: 3 additions & 3 deletions Basic/Primitive/primitive.pd
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ sub PDL::glue{
while($dim >= $x->ndims) {
$x = $x->dummy(-1,1);
}
$x = $x->xchg(0,$dim);
$x = $x->xchg(0,$dim) if 0 != $dim;
while(scalar(@_)){
my $y = shift;
Expand All @@ -1612,10 +1612,10 @@ sub PDL::glue{
while($dim >= $y->ndims) {
$y = $y->dummy(-1,1);
}
$y = $y->xchg(0,$dim);
$y = $y->xchg(0,$dim) if 0 != $dim;
$x = $x->append($y);
}
$x->xchg(0,$dim);
0 == $dim ? $x : $x->xchg(0,$dim);
}
EOD
Expand Down

0 comments on commit dddc2eb

Please sign in to comment.