Skip to content

Commit 2b90ba1

Browse files
committed
fix: use simple nested loops even for mixed signed strides
--- 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 33911df commit 2b90ba1

File tree

1 file changed

+5
-8
lines changed
  • lib/node_modules/@stdlib/ndarray/base/find/lib

1 file changed

+5
-8
lines changed

lib/node_modules/@stdlib/ndarray/base/find/lib/main.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818

1919
'use strict';
2020

21-
/* eslint-disable stdlib/no-redeclare */
22-
2321
// MODULES //
2422

25-
var iterationOrder = require( '@stdlib/ndarray/base/iteration-order' );
2623
var ndarray2object = require( '@stdlib/ndarray/base/ndarraylike2object' );
2724
var numel = require( '@stdlib/ndarray/base/numel' );
2825
var accessorfind0d = require( './0d_accessors.js' );
@@ -146,13 +143,13 @@ var MAX_DIMS = FIND.length - 1;
146143
* var out = find( [ x, sentinelValue ], predicate );
147144
* // returns 2.0
148145
*/
149-
function find( arrays, predicate, thisArg ) {
146+
function find( arrays, predicate, thisArg ) { // eslint-disable-line stdlib/no-redeclare
150147
var ndims;
151148
var shx;
152149
var sv;
153150
var x;
154151

155-
// Unpack the ndarray and standardize ndarray meta data:
152+
// Unpack the ndarrays and standardize ndarray meta data:
156153
x = ndarray2object( arrays[ 0 ] );
157154
sv = ndarray2object( arrays[ 1 ] );
158155

@@ -173,9 +170,9 @@ function find( arrays, predicate, thisArg ) {
173170
if ( numel( shx ) === 0 ) {
174171
return sv;
175172
}
176-
// Determine whether we can linear view iteration...
177-
if ( ndims <= MAX_DIMS && iterationOrder( x.strides ) !== 0 ) {
178-
// 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...
173+
// Determine whether we can avoid linear view iteration...
174+
if ( ndims <= MAX_DIMS ) {
175+
// 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; however, for mixed signed strides, iteration will not be cache-optimal, but we don't have much of a choice as loop tiling could lead to different results than cache-optimal iteration, so we just use normal nested loops for all iteration...
179176
if ( x.accessorProtocol ) {
180177
return ACCESSOR_FIND[ ndims ]( x, sv, predicate, thisArg );
181178
}

0 commit comments

Comments
 (0)