diff options
Diffstat (limited to 'Firestore/Source/Local/FSTLevelDBQueryCache.mm')
-rw-r--r-- | Firestore/Source/Local/FSTLevelDBQueryCache.mm | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/Firestore/Source/Local/FSTLevelDBQueryCache.mm b/Firestore/Source/Local/FSTLevelDBQueryCache.mm index 85b659a..97b218d 100644 --- a/Firestore/Source/Local/FSTLevelDBQueryCache.mm +++ b/Firestore/Source/Local/FSTLevelDBQueryCache.mm @@ -41,6 +41,7 @@ using firebase::firestore::model::SnapshotVersion; using leveldb::DB; using leveldb::Slice; using leveldb::Status; +using firebase::firestore::model::DocumentKeySet; @interface FSTLevelDBQueryCache () @@ -282,30 +283,28 @@ using leveldb::Status; #pragma mark Matching Key tracking -- (void)addMatchingKeys:(FSTDocumentKeySet *)keys forTargetID:(FSTTargetID)targetID { +- (void)addMatchingKeys:(const DocumentKeySet &)keys forTargetID:(FSTTargetID)targetID { // Store an empty value in the index which is equivalent to serializing a GPBEmpty message. In the // future if we wanted to store some other kind of value here, we can parse these empty values as // with some other protocol buffer (and the parser will see all default values). std::string emptyBuffer; - [keys enumerateObjectsUsingBlock:^(FSTDocumentKey *documentKey, BOOL *stop) { + for (const DocumentKey &key : keys) { self->_db.currentTransaction->Put( - [FSTLevelDBTargetDocumentKey keyWithTargetID:targetID documentKey:documentKey], - emptyBuffer); + [FSTLevelDBTargetDocumentKey keyWithTargetID:targetID documentKey:key], emptyBuffer); self->_db.currentTransaction->Put( - [FSTLevelDBDocumentTargetKey keyWithDocumentKey:documentKey targetID:targetID], - emptyBuffer); - }]; + [FSTLevelDBDocumentTargetKey keyWithDocumentKey:key targetID:targetID], emptyBuffer); + } } -- (void)removeMatchingKeys:(FSTDocumentKeySet *)keys forTargetID:(FSTTargetID)targetID { - [keys enumerateObjectsUsingBlock:^(FSTDocumentKey *key, BOOL *stop) { +- (void)removeMatchingKeys:(const DocumentKeySet &)keys forTargetID:(FSTTargetID)targetID { + for (const DocumentKey &key : keys) { self->_db.currentTransaction->Delete( [FSTLevelDBTargetDocumentKey keyWithTargetID:targetID documentKey:key]); self->_db.currentTransaction->Delete( [FSTLevelDBDocumentTargetKey keyWithDocumentKey:key targetID:targetID]); [self.garbageCollector addPotentialGarbageKey:key]; - }]; + } } - (void)removeMatchingKeysForTargetID:(FSTTargetID)targetID { @@ -331,12 +330,12 @@ using leveldb::Status; } } -- (FSTDocumentKeySet *)matchingKeysForTargetID:(FSTTargetID)targetID { +- (DocumentKeySet)matchingKeysForTargetID:(FSTTargetID)targetID { std::string indexPrefix = [FSTLevelDBTargetDocumentKey keyPrefixWithTargetID:targetID]; auto indexIterator = _db.currentTransaction->NewIterator(); indexIterator->Seek(indexPrefix); - FSTDocumentKeySet *result = [FSTDocumentKeySet keySet]; + DocumentKeySet result; FSTLevelDBTargetDocumentKey *rowKey = [[FSTLevelDBTargetDocumentKey alloc] init]; for (; indexIterator->Valid(); indexIterator->Next()) { absl::string_view indexKey = indexIterator->key(); @@ -346,7 +345,7 @@ using leveldb::Status; break; } - result = [result setByAddingObject:rowKey.documentKey]; + result = result.insert(rowKey.documentKey); } return result; |