Skip to content

Commit 4980a8f

Browse files
committed
refactor: reduce branching
--- 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 dcbe15b commit 4980a8f

File tree

1 file changed

+3
-18
lines changed
  • lib/node_modules/@stdlib/ndarray/base/every-by/lib

1 file changed

+3
-18
lines changed

lib/node_modules/@stdlib/ndarray/base/every-by/lib/main.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ var MAX_DIMS = EVERY.length - 1;
178178
function everyBy( arrays, predicate, thisArg ) {
179179
var ndims;
180180
var shx;
181-
var iox;
182181
var x;
183182

184183
// Unpack the ndarray and standardize ndarray meta data:
@@ -197,28 +196,14 @@ function everyBy( arrays, predicate, thisArg ) {
197196
if ( numel( shx ) === 0 ) {
198197
return true;
199198
}
200-
// Determine whether the ndarray is one-dimensional and thus readily translates to a one-dimensional strided array...
201-
if ( ndims === 1 ) {
199+
// Determine whether we can avoid blocked iteration...
200+
if ( ndims <= MAX_DIMS && iterationOrder( x.strides ) !== 0 ) {
201+
// So long as iteration 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...
202202
if ( x.accessorProtocol ) {
203203
return ACCESSOR_EVERY[ ndims ]( x, predicate, thisArg );
204204
}
205205
return EVERY[ ndims ]( x, predicate, thisArg );
206206
}
207-
// Determine the iteration order:
208-
iox = iterationOrder( x.strides ); // +/-1
209-
210-
// Determine whether we can avoid blocked iteration...
211-
if ( iox !== 0 ) {
212-
// Determine whether we can use simple nested loops...
213-
if ( ndims <= MAX_DIMS ) {
214-
// So long as iteration 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...
215-
if ( x.accessorProtocol ) {
216-
return ACCESSOR_EVERY[ ndims ]( x, predicate, thisArg );
217-
}
218-
return EVERY[ ndims ]( x, predicate, thisArg );
219-
}
220-
// Fall-through to blocked iteration...
221-
}
222207
// Determine whether we can perform blocked iteration...
223208
if ( ndims <= MAX_DIMS ) {
224209
if ( x.accessorProtocol ) {

0 commit comments

Comments
 (0)