Skip to content

Commit 0151774

Browse files
simplify logic for DocCSymbolInformation.matches(_:)
1 parent 1de68c5 commit 0151774

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Sources/DocCDocumentation/DocCSymbolInformation.swift

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,12 @@ package struct DocCSymbolInformation {
4444
}
4545

4646
package func matches(_ link: DocCSymbolLink) -> Bool {
47-
var linkComponents = link.components
48-
var symbolComponents = components
49-
while !linkComponents.isEmpty, !symbolComponents.isEmpty {
50-
let nextLinkComponent = linkComponents.removeLast()
51-
let nextSymbolComponent = symbolComponents.removeLast()
52-
guard nextLinkComponent.name == nextSymbolComponent.name,
53-
nextSymbolComponent.information.matches(nextLinkComponent.disambiguation)
54-
else {
55-
return false
56-
}
47+
guard link.components.count == components.count else {
48+
return false
49+
}
50+
return zip(link.components, components).allSatisfy { linkComponent, symbolComponent in
51+
linkComponent.name == symbolComponent.name && symbolComponent.information.matches(linkComponent.disambiguation)
5752
}
58-
return true
5953
}
6054
}
6155

0 commit comments

Comments
 (0)