Reuse document indexes in D&D validators

This commit is contained in:
2026-07-25 12:57:31 +00:00
parent 7a66095912
commit 97cdb01357
9 changed files with 51 additions and 27 deletions

View File

@@ -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