Rewrite an implementation to reduce compilation time
The coalescing operator for some reasons increases the build times. On my machine replacing the implementation brings down the compile time `Bag.count` from 1005ms to 13ms
This commit is contained in:
parent
bb4052fb1b
commit
00e0f5e689
|
|
@ -152,7 +152,11 @@ public struct Bag<T> : CustomDebugStringConvertible {
|
|||
- returns: Number of elements in bag.
|
||||
*/
|
||||
public var count: Int {
|
||||
return _pairs.count + (_value0 != nil ? 1 : 0) + (_value1 != nil ? 1 : 0) + (_dictionary?.count ?? 0)
|
||||
var dictionaryCount = 0
|
||||
if let dc = _dictionary?.count {
|
||||
dictionaryCount = dc
|
||||
}
|
||||
return _pairs.count + (_value0 != nil ? 1 : 0) + (_value1 != nil ? 1 : 0) + dictionaryCount
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue