Skip to content

Commit 45a6884

Browse files
committed
refactor: use array/base/flatten to avoid implicit use of utils/copy
1 parent 0b21f8d commit 45a6884

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • lib/node_modules/@stdlib/ndarray/array/lib

lib/node_modules/@stdlib/ndarray/array/lib/main.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var isAllowedCast = require( '@stdlib/ndarray/base/assert/is-allowed-data-type-c
3838
var createBuffer = require( '@stdlib/ndarray/base/buffer' );
3939
var getType = require( '@stdlib/ndarray/base/buffer-dtype' );
4040
var arrayShape = require( '@stdlib/array/shape' );
41-
var flattenArray = require( '@stdlib/utils/flatten-array' );
41+
var flatten = require( '@stdlib/array/base/flatten' );
4242
var format = require( '@stdlib/string/format' );
4343
var isArrayLikeObject = require( './is_array_like_object.js' );
4444
var getDefaults = require( './defaults.js' );
@@ -122,6 +122,7 @@ function array() {
122122
var ndims;
123123
var nopts;
124124
var opts;
125+
var osh;
125126
var len;
126127
var ord;
127128
var FLG;
@@ -280,6 +281,7 @@ function array() {
280281
len = buffer.length;
281282
} else if ( opts.flatten && isArray( buffer ) ) {
282283
shape = arrayShape( buffer );
284+
osh = shape; // cache a reference to the inferred shape
283285
ndims = shape.length;
284286
len = numel( shape );
285287
} else {
@@ -313,7 +315,7 @@ function array() {
313315
}
314316
} else if ( buffer ) {
315317
if ( btype === 'generic' && opts.flatten ) {
316-
buffer = flattenArray( buffer );
318+
buffer = flatten( buffer, osh || arrayShape( buffer ), false );
317319
}
318320
if ( buffer.length !== len ) {
319321
throw new RangeError( 'invalid arguments. Array shape is incompatible with provided data source. Number of data source elements does not match array shape.' );

0 commit comments

Comments
 (0)