Use dictionary type sugar in the standard library.

Swift SVN r19264
This commit is contained in:
Doug Gregor
2014-06-26 22:26:58 +00:00
parent 232bc5861a
commit bea1d3d9b3
4 changed files with 14 additions and 14 deletions

View File

@@ -1772,8 +1772,8 @@ struct Dictionary<KeyType : Hashable, ValueType> : Collection,
} }
@public func == <KeyType : Equatable, ValueType : Equatable>( @public func == <KeyType : Equatable, ValueType : Equatable>(
lhs: Dictionary<KeyType, ValueType>, lhs: [KeyType : ValueType],
rhs: Dictionary<KeyType, ValueType> rhs: [KeyType : ValueType]
) -> Bool { ) -> Bool {
switch (lhs._variantStorage, rhs._variantStorage) { switch (lhs._variantStorage, rhs._variantStorage) {
case (.Native(let lhsNativeOwner), .Native(let rhsNativeOwner)): case (.Native(let lhsNativeOwner), .Native(let rhsNativeOwner)):
@@ -1838,8 +1838,8 @@ struct Dictionary<KeyType : Hashable, ValueType> : Collection,
} }
@public func != <KeyType : Equatable, ValueType : Equatable>( @public func != <KeyType : Equatable, ValueType : Equatable>(
lhs: Dictionary<KeyType, ValueType>, lhs: [KeyType : ValueType],
rhs: Dictionary<KeyType, ValueType> rhs: [KeyType : ValueType]
) -> Bool { ) -> Bool {
return !(lhs == rhs) return !(lhs == rhs)
} }

View File

@@ -207,7 +207,7 @@ func _getSummary<T>(out: UnsafePointer<String>,
inout targetStream: TargetStream inout targetStream: TargetStream
) -> T { ) -> T {
var maxItemCounter = maxItems var maxItemCounter = maxItems
var visitedItems = Dictionary<ObjectIdentifier, Int>() var visitedItems = [ObjectIdentifier : Int]()
_dumpWithMirror(reflect(x), name, indent, maxDepth, _dumpWithMirror(reflect(x), name, indent, maxDepth,
&maxItemCounter, &visitedItems, &targetStream) &maxItemCounter, &visitedItems, &targetStream)
return x return x
@@ -225,7 +225,7 @@ func _getSummary<T>(out: UnsafePointer<String>,
func _dumpWithMirror<TargetStream : OutputStream>( func _dumpWithMirror<TargetStream : OutputStream>(
mirror: Mirror, name: String?, indent: Int, maxDepth: Int, mirror: Mirror, name: String?, indent: Int, maxDepth: Int,
inout maxItemCounter: Int, inout maxItemCounter: Int,
inout visitedItems: Dictionary<ObjectIdentifier, Int>, inout visitedItems: [ObjectIdentifier : Int],
inout targetStream: TargetStream inout targetStream: TargetStream
) { ) {
if maxItemCounter <= 0 { return } if maxItemCounter <= 0 { return }

View File

@@ -679,13 +679,13 @@ extension NSDictionary : DictionaryLiteralConvertible {
/// The entry point for bridging `NSDictionary` to `Dictionary`. /// The entry point for bridging `NSDictionary` to `Dictionary`.
@public func _convertNSDictionaryToDictionary<K: NSObject, V: AnyObject>( @public func _convertNSDictionaryToDictionary<K: NSObject, V: AnyObject>(
d: NSDictionary d: NSDictionary
) -> Dictionary<K, V> { ) -> [K : V] {
return Dictionary<K, V>(_cocoaDictionary: reinterpretCast(d)) return [K : V](_cocoaDictionary: reinterpretCast(d))
} }
/// The entry point for bridging `Dictionary` to `NSDictionary`. /// The entry point for bridging `Dictionary` to `NSDictionary`.
@public func _convertDictionaryToNSDictionary<KeyType, ValueType>( @public func _convertDictionaryToNSDictionary<KeyType, ValueType>(
d: Dictionary<KeyType, ValueType> d: [KeyType : ValueType]
) -> NSDictionary { ) -> NSDictionary {
switch d._variantStorage { switch d._variantStorage {
case .Native(let nativeOwner): case .Native(let nativeOwner):
@@ -771,7 +771,7 @@ extension Dictionary : _ConditionallyBridgedToObjectiveC {
@public static func bridgeFromObjectiveCConditional( @public static func bridgeFromObjectiveCConditional(
x: NSDictionary x: NSDictionary
) -> Dictionary? { ) -> Dictionary? {
let anyDict = x as Dictionary<NSObject, AnyObject> let anyDict = x as [NSObject : AnyObject]
if isBridgedVerbatimToObjectiveC(KeyType.self) && if isBridgedVerbatimToObjectiveC(KeyType.self) &&
isBridgedVerbatimToObjectiveC(ValueType.self) { isBridgedVerbatimToObjectiveC(ValueType.self) {
return Swift._dictionaryDownCastConditional(anyDict) return Swift._dictionaryDownCastConditional(anyDict)
@@ -788,7 +788,7 @@ extension Dictionary : _ConditionallyBridgedToObjectiveC {
extension NSDictionary { extension NSDictionary {
@conversion @public @conversion @public
func __conversion() -> Dictionary<NSObject, AnyObject> { func __conversion() -> [NSObject : AnyObject] {
return _convertNSDictionaryToDictionary(reinterpretCast(self)) return _convertNSDictionaryToDictionary(reinterpretCast(self))
} }
} }
@@ -802,7 +802,7 @@ extension Dictionary {
extension NSDictionary : Reflectable { extension NSDictionary : Reflectable {
@public func getMirror() -> Mirror { @public func getMirror() -> Mirror {
let dict : Dictionary<NSObject,AnyObject> = _convertNSDictionaryToDictionary(self) let dict : [NSObject : AnyObject] = _convertNSDictionaryToDictionary(self)
return reflect(dict) return reflect(dict)
} }
} }

View File

@@ -1047,8 +1047,8 @@ extension String {
/// Returns a dictionary object initialized with the keys and /// Returns a dictionary object initialized with the keys and
/// values found in the `String`. /// values found in the `String`.
@public @public
func propertyListFromStringsFileFormat() -> Dictionary<String, String> { func propertyListFromStringsFileFormat() -> [String : String] {
return _ns.propertyListFromStringsFileFormat() as Dictionary<String, String> return _ns.propertyListFromStringsFileFormat() as [String : String]
} }
// - (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet // - (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet