File tree 1 file changed +11
-16
lines changed
1 file changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -195,24 +195,19 @@ struct SocketPacket {
195
195
}
196
196
197
197
private mutating func _fillInPlaceholders( data: AnyObject ) -> AnyObject {
198
- if let str = data as? String {
199
- if let num = str [ " ~~( \\ d) " ] . groups ( ) {
200
- return binary [ Int ( num [ 1 ] ) !]
201
- } else {
202
- return str
203
- }
204
- } else if let dict = data as? NSDictionary {
205
- let newDict = NSMutableDictionary ( dictionary: dict)
206
-
207
- for (key, value) in dict {
208
- newDict [ key as! NSCopying ] = _fillInPlaceholders ( value)
209
- }
210
-
211
- return newDict
212
- } else if let arr = data as? [ AnyObject ] {
198
+ switch data {
199
+ case let string as String where string [ " ~~( \\ d) " ] . groups ( ) != nil :
200
+ return binary [ Int ( string [ " ~~( \\ d) " ] . groups ( ) ![ 1 ] ) !]
201
+ case let dict as NSDictionary :
202
+ return dict. reduce ( NSMutableDictionary ( ) , combine: { cur, keyValue in
203
+ cur [ keyValue. 0 as! NSCopying ] = _fillInPlaceholders ( keyValue. 1 )
204
+ return cur
205
+ } )
206
+ case let arr as [ AnyObject ] :
213
207
return arr. map ( { _fillInPlaceholders ( $0) } )
214
- } else {
208
+ default :
215
209
return data
210
+
216
211
}
217
212
}
218
213
}
You can’t perform that action at this time.
0 commit comments