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:
Sidharth Juyal 2016-05-31 18:59:47 +02:00
parent bb4052fb1b
commit 00e0f5e689
1 changed files with 5 additions and 1 deletions

View File

@ -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
}
/**