Rewrite the Bag.count implementation
This implementation is both short and fast in compilation times.
This commit is contained in:
parent
00e0f5e689
commit
ae9c8e3fd9
|
|
@ -152,10 +152,7 @@ public struct Bag<T> : CustomDebugStringConvertible {
|
|||
- returns: Number of elements in bag.
|
||||
*/
|
||||
public var count: Int {
|
||||
var dictionaryCount = 0
|
||||
if let dc = _dictionary?.count {
|
||||
dictionaryCount = dc
|
||||
}
|
||||
let dictionaryCount: Int = _dictionary?.count ?? 0
|
||||
return _pairs.count + (_value0 != nil ? 1 : 0) + (_value1 != nil ? 1 : 0) + dictionaryCount
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue