Skip to content

Commit b94d017

Browse files
committed
Merge PR 260
2 parents cce7c6f + 8d39a40 commit b94d017

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

Foundation/NSDictionary.swift

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,12 @@ extension Dictionary : _ObjectTypeBridgeable {
4141

4242
if x.dynamicType == NSDictionary.self || x.dynamicType == NSMutableDictionary.self {
4343
x.enumerateKeysAndObjectsUsingBlock { key, value, stop in
44-
if let k = key as? Key {
45-
if let v = value as? Value {
46-
dict[k] = v
47-
} else {
48-
failedConversion = true
49-
stop.pointee = true
50-
}
51-
} else {
44+
guard let key = key as? Key, let value = value as? Value else {
5245
failedConversion = true
5346
stop.pointee = true
47+
return
5448
}
49+
dict[key] = value
5550
}
5651
} else if x.dynamicType == _NSCFDictionary.self {
5752
let cf = x._cfObject
@@ -65,17 +60,11 @@ extension Dictionary : _ObjectTypeBridgeable {
6560
for idx in 0..<cnt {
6661
let key = unsafeBitCast(keys.advanced(by: idx).pointee!, to: AnyObject.self)
6762
let value = unsafeBitCast(values.advanced(by: idx).pointee!, to: AnyObject.self)
68-
if let k = key as? Key {
69-
if let v = value as? Value {
70-
dict[k] = v
71-
} else {
72-
failedConversion = true
73-
break
74-
}
75-
} else {
63+
guard let k = key as? Key, let v = value as? Value else {
7664
failedConversion = true
7765
break
7866
}
67+
dict[k] = v
7968
}
8069
keys.deinitialize(count: cnt)
8170
values.deinitialize(count: cnt)
@@ -255,10 +244,9 @@ public class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCodin
255244
}
256245

257246
public override func isEqual(_ object: AnyObject?) -> Bool {
258-
guard let otherObject = object where otherObject is NSDictionary else {
247+
guard let otherDictionary = object as? NSDictionary else {
259248
return false
260249
}
261-
let otherDictionary = otherObject as! NSDictionary
262250
return self.isEqualToDictionary(otherDictionary.bridge())
263251
}
264252

0 commit comments

Comments
 (0)