Mercurial > gemma
changeset 940:be7b83638ec8
Simplified line merging in generating contour lines.
Now its ~40% faster.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 09 Oct 2018 13:30:45 +0200 |
parents | a22f66acfd96 |
children | 8a80ef09a62c |
files | pkg/octree/vertex.go |
diffstat | 1 files changed, 7 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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 } } }