Skip to content

Commit

Permalink
Initialise untyped arrays with zeroes.
Browse files Browse the repository at this point in the history
Fixes square#98.
  • Loading branch information
jasondavies committed Nov 21, 2013
1 parent d3b2e4a commit e03cefb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
19 changes: 16 additions & 3 deletions crossfilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ var quicksort_sizeThreshold = 32;
var crossfilter_array8 = crossfilter_arrayUntyped,
crossfilter_array16 = crossfilter_arrayUntyped,
crossfilter_array32 = crossfilter_arrayUntyped,
crossfilter_arrayLengthen = crossfilter_identity,
crossfilter_arrayWiden = crossfilter_identity;
crossfilter_arrayLengthen = crossfilter_arrayLengthenUntyped,
crossfilter_arrayWiden = crossfilter_arrayWidenUntyped;

if (typeof Uint8Array !== "undefined") {
crossfilter_array8 = function(n) { return new Uint8Array(n); };
Expand All @@ -467,7 +467,20 @@ if (typeof Uint8Array !== "undefined") {
}

function crossfilter_arrayUntyped(n) {
return new Array(n);
var array = new Array(n), i = -1;
while (++i < n) array[i] = 0;
return array;
}

function crossfilter_arrayLengthenUntyped(array, length) {
var n = array.length;
while (n < length) array[n++] = 0;
return array;
}

function crossfilter_arrayWidenUntyped(array, width) {
if (width > 32) throw new Error("invalid array width!");
return array;
}
function crossfilter_filterExact(bisect, value) {
return function(values) {
Expand Down
2 changes: 1 addition & 1 deletion crossfilter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e03cefb

Please sign in to comment.