Combine final metadata traversal
This commit is contained in:
@@ -109,10 +109,9 @@ func (m Metadata) hasHistoricalPath(path Path) bool {
|
||||
}
|
||||
|
||||
func finalizeMetadataPaths(m *Metadata, final *document.Node, applications []historyApplication, earlier ...*document.Node) {
|
||||
m.effectivePaths = effectivePathIndex(final)
|
||||
m.effectivePaths = make(map[string]Path)
|
||||
m.historicalPaths = make(map[string][]Path)
|
||||
add := func(path Path, _ *document.Node) {
|
||||
pointer := path.String()
|
||||
addHistorical := func(path Path, pointer string) {
|
||||
for _, prior := range m.historicalPaths[pointer] {
|
||||
if matchesPathShape(path, prior) {
|
||||
return
|
||||
@@ -120,7 +119,14 @@ func finalizeMetadataPaths(m *Metadata, final *document.Node, applications []his
|
||||
}
|
||||
m.historicalPaths[pointer] = append(m.historicalPaths[pointer], path.clone())
|
||||
}
|
||||
walkDocument(final, Path{}, add)
|
||||
walkDocument(final, Path{}, func(path Path, _ *document.Node) {
|
||||
pointer := path.String()
|
||||
m.effectivePaths[pointer] = path.clone()
|
||||
addHistorical(path, pointer)
|
||||
})
|
||||
add := func(path Path, _ *document.Node) {
|
||||
addHistorical(path, path.String())
|
||||
}
|
||||
for _, tree := range earlier {
|
||||
walkDocument(tree, Path{}, add)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user