Index resolution and origin membership
This commit is contained in:
@@ -157,15 +157,12 @@ func originRepresentedByChange(path Path, origin Origin, change Change) bool {
|
||||
// A subtree replacement already records its descendants' contributions.
|
||||
// Their coordinates differ from the container's, but their sources must be
|
||||
// covered by the operation; matching only the precedence role is insufficient.
|
||||
recordedSources := make(map[string]struct{}, len(change.Origin.Locations))
|
||||
for _, recorded := range change.Origin.Locations {
|
||||
recordedSources[recorded.SourceID] = struct{}{}
|
||||
}
|
||||
for _, location := range origin.Locations {
|
||||
found := false
|
||||
for _, recorded := range change.Origin.Locations {
|
||||
if location.SourceID == recorded.SourceID {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
if _, found := recordedSources[location.SourceID]; !found {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -189,15 +186,12 @@ func originContainedBy(candidate, container Origin) bool {
|
||||
if candidate.Layer != container.Layer || candidate.Operation != container.Operation {
|
||||
return false
|
||||
}
|
||||
availableLocations := make(map[Location]struct{}, len(container.Locations))
|
||||
for _, location := range container.Locations {
|
||||
availableLocations[location] = struct{}{}
|
||||
}
|
||||
for _, location := range candidate.Locations {
|
||||
found := false
|
||||
for _, available := range container.Locations {
|
||||
if location == available {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
if _, found := availableLocations[location]; !found {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user