Skip to content

Commit f33c77b

Browse files
authored
refactor: simplify loop
Signed-off-by: Athan <kgryte@gmail.com>
1 parent 50c5f82 commit f33c77b

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

  • lib/node_modules/@stdlib/ndarray/base/append-singleton-dimensions/lib

lib/node_modules/@stdlib/ndarray/base/append-singleton-dimensions/lib/main.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function appendSingletonDimensions( x, n, writable ) {
5353
var sh;
5454
var st;
5555
var N;
56+
var s;
5657
var i;
5758

5859
sh = getShape( x, false );
@@ -68,13 +69,10 @@ function appendSingletonDimensions( x, n, writable ) {
6869
strides.push( st[ i ] );
6970
}
7071
// Append singleton dimensions...
72+
s = ( N > 0 ) ? st[ N-1 ] : st[ 0 ];
7173
for ( i = 0; i < n; i++ ) {
7274
shape.push( 1 );
73-
if ( N > 0 ) {
74-
strides.push( st[ N-1 ] );
75-
} else {
76-
strides.push( st[ 0 ] );
77-
}
75+
strides.push( s );
7876
}
7977
return new x.constructor( getDType( x ), getData( x ), shape, strides, getOffset( x ), getOrder( x ), { // eslint-disable-line max-len
8078
'readonly': !writable

0 commit comments

Comments
 (0)