Skip to content

Commit 3091a38

Browse files
committed
refactor: use utility
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent f043c89 commit 3091a38

File tree

1 file changed

+4
-5
lines changed
  • lib/node_modules/@stdlib/ndarray/base/broadcast-array/lib

1 file changed

+4
-5
lines changed

lib/node_modules/@stdlib/ndarray/base/broadcast-array/lib/main.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var getOffset = require( '@stdlib/ndarray/base/offset' );
2828
var getOrder = require( '@stdlib/ndarray/base/order' );
2929
var getDType = require( '@stdlib/ndarray/base/dtype' );
3030
var getData = require( '@stdlib/ndarray/base/data-buffer' );
31+
var zeros = require( '@stdlib/array/base/zeros' );
3132
var format = require( '@stdlib/string/format' );
3233

3334

@@ -106,11 +107,9 @@ function broadcastArray( arr, shape ) {
106107
if ( N < M ) {
107108
throw new Error( 'invalid argument. Cannot broadcast an array to a shape having fewer dimensions. Arrays can only be broadcasted to shapes having the same or more dimensions.' );
108109
}
109-
// Initialize a strides array...
110-
strides = [];
111-
for ( i = 0; i < N; i++ ) {
112-
strides.push( 0 );
113-
}
110+
// Initialize a strides array:
111+
strides = zeros( N );
112+
114113
// Determine the output array strides...
115114
st = getStrides( arr, false );
116115
for ( i = N-1; i >= 0; i-- ) {

0 commit comments

Comments
 (0)