Skip to content

Commit

Permalink
pdl() to only get_dataref/upd_data for non-zero values
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Dec 2, 2024
1 parent f725390 commit a4a687a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Basic/lib/PDL/Core.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1210,8 +1210,12 @@ sub PDL::new {
set_c($new, [0], $value);
} else {
$new->setdims([]);
${$new->get_dataref} = pack( $pack[$new->get_datatype], $value );
$new->upd_data;
if ($value) {
${$new->get_dataref} = pack( $pack[$new->get_datatype], $value );
$new->upd_data;
} else { # do nothing if 0 - allocdata already memsets to 0
$new->make_physical;
}
}
}
elsif (blessed($value)) { # Object
Expand Down

0 comments on commit a4a687a

Please sign in to comment.