Skip to content

Commit 6f51edc

Browse files
authored
Merge pull request #19604 from lorentey/resilient-reserveCapacity
[stdlib] Set, Dictionary: Make reserveCapacity non-inlinable
2 parents e080bab + 7a8b34a commit 6f51edc

File tree

6 files changed

+8
-12
lines changed

6 files changed

+8
-12
lines changed

stdlib/public/core/Dictionary.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ public struct Dictionary<Key: Hashable, Value> {
442442
/// - Parameter minimumCapacity: The minimum number of key-value pairs that
443443
/// the newly created dictionary should be able to store without
444444
/// reallocating its storage buffer.
445-
@inlinable
446-
public init(minimumCapacity: Int) {
445+
public // FIXME(reserveCapacity): Should be inlinable
446+
init(minimumCapacity: Int) {
447447
_variant = .native(_NativeDictionary(capacity: minimumCapacity))
448448
}
449449

@@ -2074,8 +2074,8 @@ extension Dictionary {
20742074
///
20752075
/// - Parameter minimumCapacity: The requested number of key-value pairs to
20762076
/// store.
2077-
@inlinable
2078-
public mutating func reserveCapacity(_ minimumCapacity: Int) {
2077+
public // FIXME(reserveCapacity): Should be inlinable
2078+
mutating func reserveCapacity(_ minimumCapacity: Int) {
20792079
_variant.reserveCapacity(minimumCapacity)
20802080
_sanityCheck(self.capacity >= minimumCapacity)
20812081
}

stdlib/public/core/DictionaryVariant.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ extension Dictionary._Variant {
109109

110110
/// Reserves enough space for the specified number of elements to be stored
111111
/// without reallocating additional storage.
112-
@inlinable
113112
internal mutating func reserveCapacity(_ capacity: Int) {
114113
switch self {
115114
case .native:

stdlib/public/core/NativeDictionary.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ extension _NativeDictionary { // ensureUnique
241241
return true
242242
}
243243

244-
@inlinable
245244
internal mutating func reserveCapacity(_ capacity: Int, isUnique: Bool) {
246245
_ = ensureUnique(isUnique: isUnique, capacity: capacity)
247246
}

stdlib/public/core/NativeSet.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ extension _NativeSet { // ensureUnique
208208
return true
209209
}
210210

211-
@inlinable
212211
internal mutating func reserveCapacity(_ capacity: Int, isUnique: Bool) {
213212
_ = ensureUnique(isUnique: isUnique, capacity: capacity)
214213
}

stdlib/public/core/Set.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ public struct Set<Element: Hashable> {
161161
/// - Parameter minimumCapacity: The minimum number of elements that the
162162
/// newly created set should be able to store without reallocating its
163163
/// storage buffer.
164-
@inlinable
165-
public init(minimumCapacity: Int) {
164+
public // FIXME(reserveCapacity): Should be inlinable
165+
init(minimumCapacity: Int) {
166166
_variant = .native(_NativeSet(capacity: minimumCapacity))
167167
}
168168

@@ -1590,8 +1590,8 @@ extension Set {
15901590
///
15911591
/// - Parameter minimumCapacity: The requested number of elements to
15921592
/// store.
1593-
@inlinable
1594-
public mutating func reserveCapacity(_ minimumCapacity: Int) {
1593+
public // FIXME(reserveCapacity): Should be inlinable
1594+
mutating func reserveCapacity(_ minimumCapacity: Int) {
15951595
_variant.reserveCapacity(minimumCapacity)
15961596
_sanityCheck(self.capacity >= minimumCapacity)
15971597
}

stdlib/public/core/SetVariant.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ extension Set._Variant {
104104

105105
/// Reserves enough space for the specified number of elements to be stored
106106
/// without reallocating additional storage.
107-
@inlinable
108107
internal mutating func reserveCapacity(_ capacity: Int) {
109108
switch self {
110109
case .native:

0 commit comments

Comments
 (0)