aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Local
diff options
context:
space:
mode:
authorGravatar zxu <zxu@google.com>2018-03-24 11:06:32 -0400
committerGravatar GitHub <noreply@github.com>2018-03-24 11:06:32 -0400
commitb3050e42d842a4aef122efd277481c46bfa88dff (patch)
treed18994e8d1c85d726ca3007f86ade676e70242b6 /Firestore/Source/Local
parent38170347b9f71798602f652e20404b565d4bd049 (diff)
port C++ `DocumentKey` to `Remote/*` (#965)
* port C++ DocumentKey to Remote's * port C++ DocumentKey to Remote's * address changes * address changes * address changes
Diffstat (limited to 'Firestore/Source/Local')
-rw-r--r--Firestore/Source/Local/FSTLocalStore.mm46
1 files changed, 24 insertions, 22 deletions
diff --git a/Firestore/Source/Local/FSTLocalStore.mm b/Firestore/Source/Local/FSTLocalStore.mm
index 922f281..1bcc6d0 100644
--- a/Firestore/Source/Local/FSTLocalStore.mm
+++ b/Firestore/Source/Local/FSTLocalStore.mm
@@ -47,6 +47,7 @@
using firebase::firestore::auth::User;
using firebase::firestore::model::DocumentKey;
using firebase::firestore::core::TargetIdGenerator;
+using firebase::firestore::model::DocumentKey;
NS_ASSUME_NONNULL_BEGIN
@@ -320,28 +321,29 @@ NS_ASSUME_NONNULL_BEGIN
}];
// TODO(klimt): This could probably be an NSMutableDictionary.
- __block FSTDocumentKeySet *changedDocKeys = [FSTDocumentKeySet keySet];
- [remoteEvent.documentUpdates
- enumerateKeysAndObjectsUsingBlock:^(FSTDocumentKey *key, FSTMaybeDocument *doc, BOOL *stop) {
- changedDocKeys = [changedDocKeys setByAddingObject:key];
- FSTMaybeDocument *existingDoc = [remoteDocuments entryForKey:key];
- // Make sure we don't apply an old document version to the remote cache, though we
- // make an exception for [SnapshotVersion noVersion] which can happen for manufactured
- // events (e.g. in the case of a limbo document resolution failing).
- if (!existingDoc || [doc.version isEqual:[FSTSnapshotVersion noVersion]] ||
- [doc.version compare:existingDoc.version] != NSOrderedAscending) {
- [remoteDocuments addEntry:doc];
- } else {
- FSTLog(
- @"FSTLocalStore Ignoring outdated watch update for %@. "
- "Current version: %@ Watch version: %@",
- key, existingDoc.version, doc.version);
- }
-
- // The document might be garbage because it was unreferenced by everything.
- // Make sure to mark it as garbage if it is...
- [self.garbageCollector addPotentialGarbageKey:key];
- }];
+ FSTDocumentKeySet *changedDocKeys = [FSTDocumentKeySet keySet];
+ for (const auto &kv : remoteEvent.documentUpdates) {
+ const DocumentKey &key = kv.first;
+ FSTMaybeDocument *doc = kv.second;
+ changedDocKeys = [changedDocKeys setByAddingObject:key];
+ FSTMaybeDocument *existingDoc = [remoteDocuments entryForKey:key];
+ // Make sure we don't apply an old document version to the remote cache, though we
+ // make an exception for [SnapshotVersion noVersion] which can happen for manufactured
+ // events (e.g. in the case of a limbo document resolution failing).
+ if (!existingDoc || [doc.version isEqual:[FSTSnapshotVersion noVersion]] ||
+ [doc.version compare:existingDoc.version] != NSOrderedAscending) {
+ [remoteDocuments addEntry:doc];
+ } else {
+ FSTLog(
+ @"FSTLocalStore Ignoring outdated watch update for %s. "
+ "Current version: %@ Watch version: %@",
+ key.ToString().c_str(), existingDoc.version, doc.version);
+ }
+
+ // The document might be garbage because it was unreferenced by everything.
+ // Make sure to mark it as garbage if it is...
+ [self.garbageCollector addPotentialGarbageKey:key];
+ }
// HACK: The only reason we allow omitting snapshot version is so we can synthesize remote events
// when we get permission denied errors while trying to resolve the state of a locally cached