Answer architecture round 3: splitArm builds a resolved reference's arm in one call
This commit is contained in:
@@ -33,16 +33,11 @@ const (
|
|||||||
// resolveRefs resolved it to; before that, a reference is whole.
|
// resolveRefs resolved it to; before that, a reference is whole.
|
||||||
func splitArm(name string, refs map[string]resolvedRef) arm {
|
func splitArm(name string, refs map[string]resolvedRef) arm {
|
||||||
if grammar.IsRef(name) {
|
if grammar.IsRef(name) {
|
||||||
r, resolved := refs[name]
|
if r, resolved := refs[name]; resolved {
|
||||||
if !resolved || len(r.tail) == 0 {
|
|
||||||
head := name
|
|
||||||
if resolved {
|
|
||||||
head = r.head
|
|
||||||
}
|
|
||||||
return pathArm(name, head, nil)
|
|
||||||
}
|
|
||||||
return pathArm(name, r.head, r.tail)
|
return pathArm(name, r.head, r.tail)
|
||||||
}
|
}
|
||||||
|
return pathArm(name, name, nil)
|
||||||
|
}
|
||||||
segs, err := grammar.SplitPath(name)
|
segs, err := grammar.SplitPath(name)
|
||||||
if err != nil || len(segs) == 1 {
|
if err != nil || len(segs) == 1 {
|
||||||
return pathArm(name, name, nil)
|
return pathArm(name, name, nil)
|
||||||
|
|||||||
Reference in New Issue
Block a user