Skip to content

Commit 8e30e22

Browse files
authored
faster array manipulations (#861)
use a tight loop to create index ranges (data has always been arrayified)
1 parent 41a5f0d commit 8e30e22

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/options.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ export function maybeZ({z, fill, stroke} = {}) {
127127

128128
// Returns a Uint32Array with elements [0, 1, 2, … data.length - 1].
129129
export function range(data) {
130-
return Uint32Array.from(data, indexOf);
130+
const n = data.length;
131+
const r = new Uint32Array(n);
132+
for (let i = 0; i < n; ++i) r[i] = i;
133+
return r;
131134
}
132135

133136
// Returns a filtered range of data given the test function.

0 commit comments

Comments
 (0)