Reuse document indexes in D&D normalization

This commit is contained in:
2026-07-25 13:01:31 +00:00
parent 97cdb01357
commit 8199d95dc1
10 changed files with 48 additions and 64 deletions

View File

@@ -77,11 +77,11 @@ func (ref UnitRef) MarshalJSON() ([]byte, error) {
return json.Marshal(ref.String())
}
func ResolveUnitID(doc *source.SourceDocument, field string, ref UnitRef) (int, error) {
func ResolveUnitID(index source.DocumentIndex, field string, ref UnitRef) (int, error) {
if ref.value <= 0 {
return 0, fmt.Errorf("%s must be positive", field)
}
if _, ok := source.UnitIndex(doc, ref.value); !ok {
if _, ok := index.Position(ref.value); !ok {
return 0, fmt.Errorf("%s %d was not found", field, ref.value)
}
return ref.value, nil