Do tagger copying with less iteration

This makes minimal difference to the benchmarks in cayley_test.go (a
variable ±5% on the bigger cases).
This commit is contained in:
kortschak 2014-08-21 15:23:30 +09:30
parent 775a253a06
commit 08e47b4a9e

View file

@ -51,14 +51,16 @@ func (t *Tagger) Fixed() map[string]Value {
} }
func (t *Tagger) CopyFrom(src Iterator) { func (t *Tagger) CopyFrom(src Iterator) {
for _, tag := range src.Tagger().Tags() { st := src.Tagger()
t.Add(tag)
}
for k, v := range src.Tagger().Fixed() { t.tags = append(t.tags, st.tags...)
t.AddFixed(k, v)
}
if t.fixedTags == nil {
t.fixedTags = make(map[string]Value, len(st.fixedTags))
}
for k, v := range st.fixedTags {
t.fixedTags[k] = v
}
} }
type Iterator interface { type Iterator interface {