Skip to content

Commit

Permalink
Subtle out of bounds checking need documenting (#128)
Browse files Browse the repository at this point in the history
* Subtle out of bounds checking need documenting

* format comment

Co-authored-by: Mike Bostock <[email protected]>
  • Loading branch information
martinfrances107 and mbostock authored Jun 4, 2021
1 parent 22d1739 commit 0b51543
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/voronoi.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,8 @@ export default class Voronoi {
case 0b1001: e0 = 0b0001; continue; // bottom-left
case 0b0001: e0 = 0b0101, x = this.xmin, y = this.ymin; break; // left
}

// Implicit out of bounds checking.
// P[j] or P[j+1] may become undefined and the conditional statement will be
// executed.
// Note: this implicitly checks for out of bounds: if P[j] or P[j+1] are
// undefined, the conditional statement will be executed.
if ((P[j] !== x || P[j + 1] !== y) && this.contains(i, x, y)) {
P.splice(j, 0, x, y), j += 2;
}
Expand Down

0 comments on commit 0b51543

Please sign in to comment.