Skip to content

Commit 0ee7adc

Browse files
committed
---
yaml --- r: 345935 b: refs/heads/master c: bd354fd h: refs/heads/master i: 345933: a4da15b 345931: 9555405 345927: d9f6ae9 345919: c339eda
1 parent 93ca831 commit 0ee7adc

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3c9b7a4b02a59713527f6c46b255482f7a34a287
2+
refs/heads/master: bd354fdfa2a87d545752ddebb37ef9eea95bf8e6
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/stdlib/public/core/ArrayCast.swift

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal func _arrayDownCastIndirect<SourceValue, TargetValue>(
2828
///
2929
/// - Note: When SourceElement and TargetElement are both bridged verbatim, type
3030
/// checking is deferred until elements are actually accessed.
31-
@inlinable // FIXME(sil-serialize-all)
31+
@inlinable //for performance reasons
3232
public func _arrayForceCast<SourceElement, TargetElement>(
3333
_ source: Array<SourceElement>
3434
) -> Array<TargetElement> {
@@ -52,21 +52,6 @@ public func _arrayForceCast<SourceElement, TargetElement>(
5252
return source.map { $0 as! TargetElement }
5353
}
5454

55-
@_fixed_layout
56-
@usableFromInline
57-
internal struct _UnwrappingFailed : Error {
58-
@inlinable
59-
internal init() {}
60-
}
61-
62-
extension Optional {
63-
@inlinable // FIXME(sil-serialize-all)
64-
internal func unwrappedOrError() throws -> Wrapped {
65-
if let x = self { return x }
66-
throw _UnwrappingFailed()
67-
}
68-
}
69-
7055
/// Called by the casting machinery.
7156
@_silgen_name("_swift_arrayDownCastConditionalIndirect")
7257
internal func _arrayDownCastConditionalIndirect<SourceValue, TargetValue>(
@@ -85,9 +70,18 @@ internal func _arrayDownCastConditionalIndirect<SourceValue, TargetValue>(
8570
/// return `nil` if any element fails to convert.
8671
///
8772
/// - Complexity: O(n), because each element must be checked.
88-
@inlinable // FIXME(sil-serialize-all)
73+
@inlinable //for performance reasons
8974
public func _arrayConditionalCast<SourceElement, TargetElement>(
9075
_ source: [SourceElement]
9176
) -> [TargetElement]? {
92-
return try? source.map { try ($0 as? TargetElement).unwrappedOrError() }
77+
var successfulCasts = ContiguousArray<TargetElement>()
78+
successfulCasts.reserveCapacity(source.count)
79+
for element in source {
80+
if let casted = element as? TargetElement {
81+
successfulCasts.append(casted)
82+
} else {
83+
return nil
84+
}
85+
}
86+
return Array(successfulCasts)
9387
}

trunk/test/api-digester/Outputs/stability-stdlib-abi.swift.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Func _int64ToStringImpl(_:_:_:_:_:) has been removed
1616
Func _uint64ToStringImpl(_:_:_:_:_:) has been removed
1717
Func _withUninitializedString(_:) has been removed
1818

19+
Func Optional.unwrappedOrError() has been removed
20+
Struct _UnwrappingFailed has been removed
21+
1922
Class _stdlib_AtomicInt has been removed
2023
Func _stdlib_atomicCompareExchangeStrongInt(object:expected:desired:) has been removed
2124
Func _stdlib_atomicCompareExchangeStrongInt32(object:expected:desired:) has been removed

0 commit comments

Comments
 (0)