Skip to content

Commit 1b9aea2

Browse files
committed
Revert enumerability change due to performance impact
Setting inherited "private" properties to non-enumerable has a non- negligible performance impact. While possible for a user to extract all enumerable keys from an ndarray, this should not be common. For the stdlib REPL, we should handle ndarrays as a special case when displaying as a return value. This applies similarly to other JS objects, such as typed arrays.
1 parent 26d67e0 commit 1b9aea2

File tree

1 file changed

+0
-13
lines changed
  • lib/node_modules/@stdlib/ndarray/ctor/lib

1 file changed

+0
-13
lines changed

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

-13
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
// MODULES //
2222

2323
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
24-
var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' );
2524
var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' );
2625
var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' );
2726
var isBuffer = require( '@stdlib/assert/is-buffer' );
@@ -35,7 +34,6 @@ var isBufferLengthCompatible = require( '@stdlib/ndarray/base/assert/is-buffer-l
3534
var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' );
3635
var baseCtor = require( '@stdlib/ndarray/base/memoized-ctor' );
3736
var inherit = require( '@stdlib/utils/inherit' );
38-
var objectKeys = require( '@stdlib/utils/keys' );
3937
var defaults = require( './defaults.json' );
4038
var igetValue = require( './iget.js' );
4139
var isetValue = require( './iset.js' );
@@ -139,11 +137,8 @@ function ctor( dtype, ndims, options ) {
139137
*/
140138
function ndarray( buffer, shape, strides, offset, order ) {
141139
/* eslint-disable no-invalid-this */
142-
var keys;
143140
var sh;
144141
var st;
145-
var k;
146-
var i;
147142
if ( !(this instanceof ndarray) ) {
148143
return new ndarray( buffer, shape, strides, offset, order );
149144
}
@@ -185,14 +180,6 @@ function ctor( dtype, ndims, options ) {
185180
// Cache references to the parent constructor and parent constructor methods:
186181
setReadOnly( this, '_parent', parent );
187182

188-
// Make all inherited "private" properties non-enumerable...
189-
keys = objectKeys( this );
190-
for ( i = 0; i < keys.length; i++ ) {
191-
k = keys[ i ];
192-
if ( k[ 0 ] === '_' ) {
193-
setNonEnumerable( this, k, this[ k ] );
194-
}
195-
}
196183
return this;
197184

198185
/* eslint-enable no-invalid-this */

0 commit comments

Comments
 (0)