From 00e0f5e68946abd4c2bf646319347e2f964a46de Mon Sep 17 00:00:00 2001 From: Sidharth Juyal Date: Tue, 31 May 2016 18:59:47 +0200 Subject: [PATCH] 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 --- RxSwift/DataStructures/Bag.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RxSwift/DataStructures/Bag.swift b/RxSwift/DataStructures/Bag.swift index fe074dec..92605d4a 100644 --- a/RxSwift/DataStructures/Bag.swift +++ b/RxSwift/DataStructures/Bag.swift @@ -152,7 +152,11 @@ public struct Bag : 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 } /**