Reuse cached pointers when ordering resolution changes
This commit is contained in:
@@ -2,8 +2,9 @@ package engine
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"go.maximumdirect.net/configkit/internal/document"
|
||||
"slices"
|
||||
|
||||
"go.maximumdirect.net/configkit/internal/document"
|
||||
)
|
||||
|
||||
type documentDeltaKind uint8
|
||||
@@ -24,6 +25,10 @@ type documentDelta struct {
|
||||
func compareConfigurationValues(before, after *document.Node) []documentDelta {
|
||||
var deltas []documentDelta
|
||||
compareConfigurationValue(before, after, Path{}, &deltas)
|
||||
return sortDocumentDeltas(deltas)
|
||||
}
|
||||
|
||||
func sortDocumentDeltas(deltas []documentDelta) []documentDelta {
|
||||
type orderedDelta struct {
|
||||
delta documentDelta
|
||||
pointer string
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"slices"
|
||||
|
||||
"go.maximumdirect.net/configkit/internal/document"
|
||||
)
|
||||
import "go.maximumdirect.net/configkit/internal/document"
|
||||
|
||||
// compareResolutionValues reports field-level changes at stable list positions.
|
||||
func compareResolutionValues(before, after *document.Node, correspondence ...resolutionCorrespondence) []documentDelta {
|
||||
@@ -61,11 +56,5 @@ func compareResolutionValues(before, after *document.Node, correspondence ...res
|
||||
}
|
||||
}
|
||||
compare(before, after, Path{})
|
||||
slices.SortFunc(deltas, func(a, b documentDelta) int {
|
||||
if order := cmp.Compare(a.path.String(), b.path.String()); order != 0 {
|
||||
return order
|
||||
}
|
||||
return int(a.kind) - int(b.kind)
|
||||
})
|
||||
return deltas
|
||||
return sortDocumentDeltas(deltas)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user