Skip to content

Commit b981bc3

Browse files
committed
refactor: avoid repeated property access
1 parent 550285b commit b981bc3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/node_modules/@stdlib/array/to-fancy/lib/set_elements.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ function setElements( target, property, value, ctx ) {
6565
dt = dtype( value ) || 'generic';
6666
} else {
6767
// When provided a "scalar", we need to check whether the value can be safely cast to the target array data type:
68-
err = ctx.validator( value, ctx.dtype );
68+
dt = ctx.dtype;
69+
err = ctx.validator( value, dt );
6970
if ( err ) {
7071
throw err;
7172
}
@@ -75,8 +76,7 @@ function setElements( target, property, value, ctx ) {
7576
v = value;
7677
}
7778
// As the scalar can be safely cast, convert the scalar to an array having the same data type as the target array to allow for broadcasting during assignment:
78-
v = scalar2array( v, ctx.dtype );
79-
dt = ctx.dtype;
79+
v = scalar2array( v, dt );
8080
}
8181
if ( idx.type === 'int' ) {
8282
try {

0 commit comments

Comments
 (0)