Share the source index with validators
This commit is contained in:
@@ -21,10 +21,16 @@ func NewSourceRefOrder(doc *source.SourceDocument) SourceRefOrder {
|
||||
// NewSourceRefOrderForSource uses a borrowed whole-source index when provided.
|
||||
// The caller must supply an index for doc; otherwise one is built locally.
|
||||
func NewSourceRefOrderForSource(doc *source.SourceDocument, index *source.DocumentIndex) SourceRefOrder {
|
||||
return NewSourceRefOrderFromIndex(DocumentIndexForSource(doc, index))
|
||||
}
|
||||
|
||||
// DocumentIndexForSource borrows the supplied whole-source snapshot, or builds
|
||||
// one locally when omitted. A supplied index must match doc's unchanged ID/order.
|
||||
func DocumentIndexForSource(doc *source.SourceDocument, index *source.DocumentIndex) source.DocumentIndex {
|
||||
if index != nil {
|
||||
return NewSourceRefOrderFromIndex(*index)
|
||||
return *index
|
||||
}
|
||||
return NewSourceRefOrder(doc)
|
||||
return source.NewDocumentIndex(doc)
|
||||
}
|
||||
|
||||
// NewSourceRefOrderFromIndex captures source identity and unit positions from
|
||||
|
||||
Reference in New Issue
Block a user