# HG changeset patch # User Sascha L. Teichmann # Date 1542303046 -3600 # Node ID ba0d8c327b0b282b5ee859dec2a64bf0fc61c2df # Parent 7e6fce79ddc8060ef2767994502370058f5df2cf Made code more idiomatic. diff -r 7e6fce79ddc8 -r ba0d8c327b0b pkg/octree/contours.go --- a/pkg/octree/contours.go Thu Nov 15 18:27:27 2018 +0100 +++ b/pkg/octree/contours.go Thu Nov 15 18:30:46 2018 +0100 @@ -27,7 +27,7 @@ cond *sync.Cond } -func NewContorResult(height float64) *ContourResult { +func NewContourResult(height float64) *ContourResult { cr := ContourResult{Height: height} cr.cond = sync.NewCond(&cr.mu) return &cr @@ -57,9 +57,10 @@ func DoContours(tree *Tree, heights []float64, store func(*ContourResult)) { - var contours []*ContourResult - for i := 0; i < len(heights); i++ { - contours = append(contours, NewContorResult(heights[i])) + contours := make([]*ContourResult, len(heights)) + + for i, h := range heights { + contours[i] = NewContourResult(h) } jobs := make(chan *ContourResult)