micro optimisation: avoid some unnecessary copying

This commit is contained in:
Matthias Radestock
2016-07-29 18:56:06 +01:00
parent 0525a2a95e
commit 15cf1e16b2
2 changed files with 6 additions and 4 deletions

View File

@@ -163,9 +163,10 @@ func (t TableTemplates) Merge(other TableTemplates) TableTemplates {
}
for k, v := range other {
if existing, ok := result[k]; ok {
v = v.Merge(existing)
result[k] = v.Merge(existing)
} else {
result[k] = v
}
result[k] = v
}
return result
}

View File

@@ -181,9 +181,10 @@ func (n Nodes) Merge(other Nodes) Nodes {
}
for k, v := range other {
if n, ok := cp[k]; ok { // don't overwrite
v = v.Merge(n)
cp[k] = v.Merge(n)
} else {
cp[k] = v
}
cp[k] = v
}
return cp
}