Skip to content

Commit 3cebbe5

Browse files
Om-A-osckgryte
andauthored
refactor: perform explicit push when using generic arrays
PR-URL: #9873 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 4a2e646 commit 3cebbe5

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

lib/node_modules/@stdlib/stats/ranks/benchmark/benchmark.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isArray = require( '@stdlib/assert/is-array' );
2626
var pkg = require( './../package.json' ).name;
2727
var ranks = require( './../lib' );
@@ -32,18 +32,15 @@ var ranks = require( './../lib' );
3232
bench( pkg, function benchmark( b ) {
3333
var result;
3434
var arr;
35-
var len;
3635
var i;
3736

38-
arr = new Array( 100 );
39-
len = arr.length;
40-
for ( i = 0; i < len; i++ ) {
41-
arr[ i ] = ( randu()*100.0 ) - 50.0;
42-
}
37+
arr = uniform( 100, -50.0, 50.0, {
38+
'dtype': 'generic'
39+
});
4340

4441
b.tic();
4542
for ( i = 0; i < b.iterations; i++ ) {
46-
arr[ 0 ] = ( randu()*100.0 ) - 50.0;
43+
arr[ 0 ] = i;
4744
result = ranks( arr );
4845
if ( typeof result !== 'object' ) {
4946
b.fail( 'should return an object' );

lib/node_modules/@stdlib/stats/ranks/lib/order.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ function order( x ) {
5252
var arr;
5353
var i;
5454

55-
arr = new Array( x.length );
55+
arr = [];
5656
for ( i = 0; i < x.length; i++ ) {
57-
arr[ i ] = i;
57+
arr.push( i );
5858
}
5959
return arr.sort( compare );
6060

0 commit comments

Comments
 (0)