Skip to content

Commit

Permalink
fix(partition): zero value sectors cause max stack call
Browse files Browse the repository at this point in the history
  • Loading branch information
markov00 committed Nov 28, 2023
1 parent 95e970f commit e314c70
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ function layVector(
areaAccessor: (e: ArrayEntry) => number,
): LayoutElement {
const area = nodes.reduce((p, n) => p + areaAccessor(n), 0);
const dependentSize = area / independentSize; // here we lose a bit of accuracy
const dependentSize = independentSize === 0 ? 0 : area / independentSize; // here we lose a bit of accuracy
let currentOffset = 0;
const sectionOffsets = [currentOffset];
const sectionSizes = nodes.map((e, i) => {
const sectionSize = areaAccessor(e) / dependentSize; // here we gain back a bit of accuracy
const sectionSize = dependentSize === 0 ? 0 : areaAccessor(e) / dependentSize; // here we gain back a bit of accuracy
if (i < nodes.length - 1) sectionOffsets.push((currentOffset += sectionSize));
return sectionSize;
});
Expand Down

0 comments on commit e314c70

Please sign in to comment.