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:
parent
775a253a06
commit
08e47b4a9e
1 changed files with 8 additions and 6 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue