mirror of
https://github.com/apple/swift-certificates
synced 2026-11-22 04:20:39 +00:00
Prefer appending to init
This commit is contained in:
1 parent
d2ef4164b1
commit
389c9c4706
1 file changed
+8
-7
@@ -64,7 +64,7 @@ public struct Verifier {
|
||||
continue
|
||||
}
|
||||
|
||||
let nextChain = CandidatePartialChain(appending: parent, to: nextPartialCandidate)
|
||||
let nextChain = nextPartialCandidate.appending(parent)
|
||||
partialChains.append(nextChain)
|
||||
}
|
||||
}
|
||||
@@ -117,12 +117,6 @@ fileprivate struct CandidatePartialChain {
|
||||
self.currentTip = leaf
|
||||
}
|
||||
|
||||
init(appending newElement: Certificate, to partialChain: CandidatePartialChain) {
|
||||
self.chain = partialChain.chain
|
||||
self.chain.append(partialChain.currentTip)
|
||||
self.currentTip = newElement
|
||||
}
|
||||
|
||||
/// Whether this partial chain already contains this certificate.
|
||||
func contains(certificate: Certificate) -> Bool {
|
||||
// We don't do direct equality, as RFC 4158 § 2.4.1 notes that even certs that aren't
|
||||
@@ -151,6 +145,13 @@ fileprivate struct CandidatePartialChain {
|
||||
match(self.currentTip, certificate)
|
||||
)
|
||||
}
|
||||
|
||||
func appending(_ newElement: Certificate) -> CandidatePartialChain {
|
||||
var newChain = self
|
||||
newChain.chain.append(newChain.currentTip)
|
||||
newChain.currentTip = newElement
|
||||
return newChain
|
||||
}
|
||||
}
|
||||
|
||||
extension Array where Element == Certificate {
|
||||
|
||||
Reference in new issue
Block a user