Skip to content

Commit 176abc2

Browse files
authored
Cache curves to avoid repeatedly reallocating state (#391)
Motivation We shouldn't repeatedly reconstruct static data Modifications - Turn the groups into static lets instead of computed properties Result Fewer allocations
1 parent 64a4de0 commit 176abc2

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

Sources/Crypto/Keys/EC/BoringSSL/NISTCurvesKeys_boring.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,20 @@ extension OpenSSLSupportedNISTCurve {
3636

3737
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
3838
extension P256: OpenSSLSupportedNISTCurve {
39-
@inlinable
40-
static var group: BoringSSLEllipticCurveGroup {
41-
try! BoringSSLEllipticCurveGroup(.p256)
42-
}
39+
@usableFromInline
40+
static let group = try! BoringSSLEllipticCurveGroup(.p256)
4341
}
4442

4543
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
4644
extension P384: OpenSSLSupportedNISTCurve {
47-
@inlinable
48-
static var group: BoringSSLEllipticCurveGroup {
49-
try! BoringSSLEllipticCurveGroup(.p384)
50-
}
45+
@usableFromInline
46+
static let group = try! BoringSSLEllipticCurveGroup(.p384)
5147
}
5248

5349
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
5450
extension P521: OpenSSLSupportedNISTCurve {
55-
@inlinable
56-
static var group: BoringSSLEllipticCurveGroup {
57-
try! BoringSSLEllipticCurveGroup(.p521)
58-
}
51+
@usableFromInline
52+
static let group = try! BoringSSLEllipticCurveGroup(.p521)
5953
}
6054

6155
@usableFromInline

0 commit comments

Comments
 (0)