# HG changeset patch # User Sascha L. Teichmann # Date 1539084645 -7200 # Node ID be7b83638ec8d59d4a73c38303ae641897d6c1cb # Parent a22f66acfd9685f93c1be7e20efd8038d00c3c73 Simplified line merging in generating contour lines. Now its ~40% faster. diff -r a22f66acfd96 -r be7b83638ec8 pkg/octree/vertex.go --- a/pkg/octree/vertex.go Tue Oct 09 00:37:23 2018 +0200 +++ b/pkg/octree/vertex.go Tue Oct 09 13:30:45 2018 +0200 @@ -425,28 +425,23 @@ for head, lines := range heads { for i, line := range *lines { tail := quant(line[len(line)-1]) - if hs := heads[tail]; hs != nil { + for hs := heads[tail]; hs != nil && len(*hs) > 0; hs = heads[tail] { l := len(*hs) last := (*hs)[l-1] - if l == 1 { - delete(heads, tail) - } else { - (*hs)[l-1] = nil - *hs = (*hs)[:l-1] - } + (*hs)[l-1] = nil + *hs = (*hs)[:l-1] line = line.Join(last) - if head == quant(line[len(line)-1]) { // its a ring + if tail = quant(line[len(line)-1]); head == tail { // its a ring out = append(out, line) // remove from current lines copy((*lines)[i:], (*lines)[i+1:]) (*lines)[len(*lines)-1] = nil *lines = (*lines)[:len(*lines)-1] - } else { - // overwrite in current lines - (*lines)[i] = line + goto again } - goto again + // overwrite in current lines + (*lines)[i] = line } } }