aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Local/FSTMemoryPersistence.mm
diff options
context:
space:
mode:
Diffstat (limited to 'Firestore/Source/Local/FSTMemoryPersistence.mm')
-rw-r--r--Firestore/Source/Local/FSTMemoryPersistence.mm19
1 files changed, 12 insertions, 7 deletions
diff --git a/Firestore/Source/Local/FSTMemoryPersistence.mm b/Firestore/Source/Local/FSTMemoryPersistence.mm
index e301820..ba71f9c 100644
--- a/Firestore/Source/Local/FSTMemoryPersistence.mm
+++ b/Firestore/Source/Local/FSTMemoryPersistence.mm
@@ -16,7 +16,8 @@
#import "Firestore/Source/Local/FSTMemoryPersistence.h"
-#import "Firestore/Source/Auth/FSTUser.h"
+#include <unordered_map>
+
#import "Firestore/Source/Local/FSTMemoryMutationQueue.h"
#import "Firestore/Source/Local/FSTMemoryQueryCache.h"
#import "Firestore/Source/Local/FSTMemoryRemoteDocumentCache.h"
@@ -24,12 +25,15 @@
#import "Firestore/Source/Local/FSTWriteGroupTracker.h"
#import "Firestore/Source/Util/FSTAssert.h"
+#include "Firestore/core/src/firebase/firestore/auth/user.h"
+
+using firebase::firestore::auth::HashUser;
+using firebase::firestore::auth::User;
+
NS_ASSUME_NONNULL_BEGIN
@interface FSTMemoryPersistence ()
@property(nonatomic, strong, nonnull) FSTWriteGroupTracker *writeGroupTracker;
-@property(nonatomic, strong, nonnull)
- NSMutableDictionary<FSTUser *, id<FSTMutationQueue>> *mutationQueues;
@property(nonatomic, assign, getter=isStarted) BOOL started;
@end
@@ -46,6 +50,8 @@ NS_ASSUME_NONNULL_BEGIN
/** The FSTRemoteDocumentCache representing the persisted cache of remote documents. */
FSTMemoryRemoteDocumentCache *_remoteDocumentCache;
+
+ std::unordered_map<User, id<FSTMutationQueue>, HashUser> _mutationQueues;
}
+ (instancetype)persistence {
@@ -57,7 +63,6 @@ NS_ASSUME_NONNULL_BEGIN
_writeGroupTracker = [FSTWriteGroupTracker tracker];
_queryCache = [[FSTMemoryQueryCache alloc] init];
_remoteDocumentCache = [[FSTMemoryRemoteDocumentCache alloc] init];
- _mutationQueues = [NSMutableDictionary dictionary];
}
return self;
}
@@ -75,11 +80,11 @@ NS_ASSUME_NONNULL_BEGIN
self.started = NO;
}
-- (id<FSTMutationQueue>)mutationQueueForUser:(FSTUser *)user {
- id<FSTMutationQueue> queue = self.mutationQueues[user];
+- (id<FSTMutationQueue>)mutationQueueForUser:(const User &)user {
+ id<FSTMutationQueue> queue = _mutationQueues[user];
if (!queue) {
queue = [FSTMemoryMutationQueue mutationQueue];
- self.mutationQueues[user] = queue;
+ _mutationQueues[user] = queue;
}
return queue;
}