Skip to content

Commit 53834fe

Browse files
committed
refactor: use non-strided loop
1 parent 766432f commit 53834fe

File tree

1 file changed

+2
-37
lines changed
  • lib/node_modules/@stdlib/array/base/any/lib

1 file changed

+2
-37
lines changed

lib/node_modules/@stdlib/array/base/any/lib/main.js

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -58,41 +58,6 @@ function internal( x ) {
5858
return false;
5959
}
6060

61-
/**
62-
* Tests whether at least one element in a complex number array is truthy.
63-
*
64-
* @private
65-
* @param {Collection} x - underlying data buffer
66-
* @returns {boolean} boolean indicating whether at least one element is truthy
67-
*
68-
* @example
69-
* var x = [ 0, 0, 1, 0 ];
70-
*
71-
* var out = internalComplex( x );
72-
* // returns true
73-
*
74-
* @example
75-
* var x = [ 1, 2, 0, 0 ];
76-
*
77-
* var out = internalComplex( x );
78-
* // returns true
79-
*
80-
* @example
81-
* var x = [ 0, 0, 0, 0 ];
82-
*
83-
* var out = internalComplex( x );
84-
* // returns false
85-
*/
86-
function internalComplex( x ) {
87-
var i;
88-
for ( i = 0; i < x.length; i += 2 ) {
89-
if ( x[ i ] || x[ i+1 ] ) {
90-
return true;
91-
}
92-
}
93-
return false;
94-
}
95-
9661
/**
9762
* Tests whether at least one element in an array is truthy.
9863
*
@@ -160,10 +125,10 @@ function any( x ) {
160125
if ( obj.accessorProtocol ) {
161126
// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero...
162127
if ( isComplex128Array( x ) ) {
163-
return internalComplex( reinterpret128( x, 0 ) );
128+
return internal( reinterpret128( x, 0 ) );
164129
}
165130
if ( isComplex64Array( x ) ) {
166-
return internalComplex( reinterpret64( x, 0 ) );
131+
return internal( reinterpret64( x, 0 ) );
167132
}
168133
return accessors( obj );
169134
}

0 commit comments

Comments
 (0)