From 6d51ff4a127f6ef58218d7332597e705497b8520 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 29 Dec 2019 23:27:58 +0900 Subject: [PATCH] vector/internal/math: Optimization --- vector/internal/math/triangulate.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vector/internal/math/triangulate.go b/vector/internal/math/triangulate.go index 4dff88db2..30b85c79e 100644 --- a/vector/internal/math/triangulate.go +++ b/vector/internal/math/triangulate.go @@ -127,11 +127,11 @@ func Triangulate(pts []Point) []uint16 { pt0 := pts[i0] pt1 := pts[i1] pt2 := pts[i2] - for j := range currentIndices { - if l := len(currentIndices); j == (i+l-1)%l || j == i || j == (i+1)%l { + for _, j := range currentIndices { + if j == i0 || j == i1 || j == i2 { continue } - if InTriangle(pts[currentIndices[j]], pt0, pt1, pt2) { + if InTriangle(pts[j], pt0, pt1, pt2) { // If the triangle includes another point, the triangle is not an ear. continue index }