Move tag handling out into graph.Tagger
This commit is contained in:
parent
0238332ca3
commit
1604dca737
28 changed files with 315 additions and 159 deletions
|
|
@ -82,7 +82,7 @@ func (it *And) Optimize() (graph.Iterator, bool) {
|
|||
}
|
||||
|
||||
// Move the tags hanging on us (like any good replacement).
|
||||
newAnd.CopyTagsFrom(it)
|
||||
newAnd.tags.CopyFrom(it)
|
||||
|
||||
newAnd.optimizeCheck()
|
||||
|
||||
|
|
@ -213,11 +213,11 @@ func (it *And) optimizeCheck() {
|
|||
func (it *And) getSubTags() map[string]struct{} {
|
||||
tags := make(map[string]struct{})
|
||||
for _, sub := range it.SubIterators() {
|
||||
for _, tag := range sub.Tags() {
|
||||
for _, tag := range sub.Tagger().Tags() {
|
||||
tags[tag] = struct{}{}
|
||||
}
|
||||
}
|
||||
for _, tag := range it.Tags() {
|
||||
for _, tag := range it.tags.Tags() {
|
||||
tags[tag] = struct{}{}
|
||||
}
|
||||
return tags
|
||||
|
|
@ -227,13 +227,14 @@ func (it *And) getSubTags() map[string]struct{} {
|
|||
// src itself, and moves them to dst.
|
||||
func moveTagsTo(dst graph.Iterator, src *And) {
|
||||
tags := src.getSubTags()
|
||||
for _, tag := range dst.Tags() {
|
||||
for _, tag := range dst.Tagger().Tags() {
|
||||
if _, ok := tags[tag]; ok {
|
||||
delete(tags, tag)
|
||||
}
|
||||
}
|
||||
dt := dst.Tagger()
|
||||
for k := range tags {
|
||||
dst.AddTag(k)
|
||||
dt.Add(k)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue