Skip to content

Commit 9934f2c

Browse files
committed
refactor: only branch when y is backed by an accessor array
--- 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 7378f4d commit 9934f2c

File tree

1 file changed

+6
-6
lines changed
  • lib/node_modules/@stdlib/ndarray/base/unary-reduce-subarray/lib

1 file changed

+6
-6
lines changed

lib/node_modules/@stdlib/ndarray/base/unary-reduce-subarray/lib/main.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ function unaryReduceSubarray( fcn, arrays, dims, options ) { // eslint-disable-l
323323
}
324324
// Determine whether we can avoid iteration altogether...
325325
if ( K === 0 ) {
326-
if ( x.accessorProtocol || y.accessorProtocol ) {
326+
if ( y.accessorProtocol ) {
327327
return ACCESSOR_UNARY[ K ]( fcn, arr, opts );
328328
}
329329
return UNARY[ K ]( fcn, arr, opts );
@@ -376,7 +376,7 @@ function unaryReduceSubarray( fcn, arrays, dims, options ) { // eslint-disable-l
376376

377377
// Determine whether we only have one loop dimension and can thus readily perform one-dimensional iteration...
378378
if ( K === 1 ) {
379-
if ( x.accessorProtocol || y.accessorProtocol ) {
379+
if ( y.accessorProtocol ) {
380380
return ACCESSOR_UNARY[ K ]( fcn, arr, views, sl, opts );
381381
}
382382
return UNARY[ K ]( fcn, arr, views, sl, opts );
@@ -396,7 +396,7 @@ function unaryReduceSubarray( fcn, arrays, dims, options ) { // eslint-disable-l
396396
arr[ j ].strides = [ arr[j].strides[i] ];
397397
}
398398
sl = [ sl[i] ];
399-
if ( x.accessorProtocol || y.accessorProtocol ) {
399+
if ( y.accessorProtocol ) {
400400
return ACCESSOR_UNARY[ 1 ]( fcn, arr, views, sl, opts );
401401
}
402402
return UNARY[ 1 ]( fcn, arr, views, sl, opts );
@@ -407,7 +407,7 @@ function unaryReduceSubarray( fcn, arrays, dims, options ) { // eslint-disable-l
407407
// Determine whether we can avoid blocked iteration...
408408
if ( iox !== 0 && ioy !== 0 && iox === ioy && K <= MAX_DIMS ) {
409409
// So long as iteration for each respective array always moves in the same direction (i.e., no mixed sign strides), we can leverage cache-optimal (i.e., normal) nested loops without resorting to blocked iteration...
410-
if ( x.accessorProtocol || y.accessorProtocol ) {
410+
if ( y.accessorProtocol ) {
411411
return ACCESSOR_UNARY[ K ]( fcn, arr, views, sl, opts );
412412
}
413413
return UNARY[ K ]( fcn, arr, views, sl, opts );
@@ -416,13 +416,13 @@ function unaryReduceSubarray( fcn, arrays, dims, options ) { // eslint-disable-l
416416

417417
// Determine whether we can perform blocked iteration...
418418
if ( K <= MAX_DIMS ) {
419-
if ( x.accessorProtocol || y.accessorProtocol ) {
419+
if ( y.accessorProtocol ) {
420420
return BLOCKED_ACCESSOR_UNARY[ K-2 ]( fcn, arr, views, sl, opts );
421421
}
422422
return BLOCKED_UNARY[ K-2 ]( fcn, arr, views, sl, opts );
423423
}
424424
// Fall-through to linear view iteration without regard for how data is stored in memory (i.e., take the slow path)...
425-
if ( x.accessorProtocol || y.accessorProtocol ) {
425+
if ( y.accessorProtocol ) {
426426
return accessorunarynd( fcn, arr, views, sl, opts );
427427
}
428428
unarynd( fcn, arr, views, sl, opts );

0 commit comments

Comments
 (0)