Reuse document indexes in D&D validators
This commit is contained in:
@@ -15,10 +15,16 @@ type SourceRefOrder struct {
|
||||
|
||||
// NewSourceRefOrder captures the source identity and unit positions from doc.
|
||||
func NewSourceRefOrder(doc *source.SourceDocument) SourceRefOrder {
|
||||
return NewSourceRefOrderWithIndex(doc, source.NewDocumentIndex(doc))
|
||||
}
|
||||
|
||||
// NewSourceRefOrderWithIndex captures source identity with a supplied
|
||||
// document index for source-reference comparison and canonicalization.
|
||||
func NewSourceRefOrderWithIndex(doc *source.SourceDocument, index source.DocumentIndex) SourceRefOrder {
|
||||
if doc == nil {
|
||||
return SourceRefOrder{}
|
||||
}
|
||||
return SourceRefOrder{sourceID: doc.ID, index: source.NewDocumentIndex(doc)}
|
||||
return SourceRefOrder{sourceID: doc.ID, index: index}
|
||||
}
|
||||
|
||||
// Less orders references by source identity, then document positions when
|
||||
|
||||
Reference in New Issue
Block a user