Skip to content

Commit f33e99e

Browse files
committed
Reuse buffer
1 parent 9879bf4 commit f33e99e

File tree

1 file changed

+7
-2
lines changed
  • lib/node_modules/@stdlib/ndarray/base/assert/is-buffer-length-compatible/lib

1 file changed

+7
-2
lines changed

lib/node_modules/@stdlib/ndarray/base/assert/is-buffer-length-compatible/lib/main.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
var minmax = require( '@stdlib/ndarray/base/minmax-view-buffer-index' );
2424

2525

26+
// VARIABLES //
27+
28+
var BUFFER = [ 0, 0 ]; // WARNING: in C, this would not be thread safe
29+
30+
2631
// MAIN //
2732

2833
/**
@@ -52,10 +57,10 @@ var minmax = require( '@stdlib/ndarray/base/minmax-view-buffer-index' );
5257
*/
5358
function isBufferLengthCompatible( len, shape, strides, offset ) {
5459
// Determine the minimum and maximum linear indices which are accessible by the array view:
55-
var idx = minmax( shape, strides, offset );
60+
minmax( BUFFER, shape, strides, offset );
5661

5762
// If the indices are "inbounds", then the buffer length is compatible:
58-
return ( idx[ 0 ] >= 0 && idx[ 1 ] < len );
63+
return ( BUFFER[ 0 ] >= 0 && BUFFER[ 1 ] < len );
5964
}
6065

6166

0 commit comments

Comments
 (0)