From 0b51543123eb996a44c088866d9f5791f3143991 Mon Sep 17 00:00:00 2001 From: martin frances Date: Fri, 4 Jun 2021 18:51:47 +0100 Subject: [PATCH] Subtle out of bounds checking need documenting (#128) * Subtle out of bounds checking need documenting * format comment Co-authored-by: Mike Bostock --- src/voronoi.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/voronoi.js b/src/voronoi.js index d179df7..97d388b 100644 --- a/src/voronoi.js +++ b/src/voronoi.js @@ -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; }