From a080e481b5e6fcbc2b645920051cf20fc8cad7a7 Mon Sep 17 00:00:00 2001 From: Gil Date: Sat, 5 May 2018 08:10:51 -0700 Subject: Port FSTDocumentKeySet to C++ DocumentKeySet (#1229) * Define a Comparator for DocumentKey * Automated migration from FSTDocumentKeySet to DocumentKeySet * Manual fixups for DocumentKeySet * Delete FSTDocumentKeySet --- Firestore/Example/Tests/Util/FSTHelpers.mm | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'Firestore/Example/Tests/Util/FSTHelpers.mm') diff --git a/Firestore/Example/Tests/Util/FSTHelpers.mm b/Firestore/Example/Tests/Util/FSTHelpers.mm index 92eb730..dbd19aa 100644 --- a/Firestore/Example/Tests/Util/FSTHelpers.mm +++ b/Firestore/Example/Tests/Util/FSTHelpers.mm @@ -44,6 +44,7 @@ #include "Firestore/core/src/firebase/firestore/model/database_id.h" #include "Firestore/core/src/firebase/firestore/model/document_key.h" +#include "Firestore/core/src/firebase/firestore/model/document_key_set.h" #include "Firestore/core/src/firebase/firestore/model/field_mask.h" #include "Firestore/core/src/firebase/firestore/model/field_transform.h" #include "Firestore/core/src/firebase/firestore/model/field_value.h" @@ -66,6 +67,7 @@ using firebase::firestore::model::Precondition; using firebase::firestore::model::ResourcePath; using firebase::firestore::model::ServerTimestampTransform; using firebase::firestore::model::TransformOperation; +using firebase::firestore::model::DocumentKeySet; NS_ASSUME_NONNULL_BEGIN @@ -146,14 +148,6 @@ FSTDocumentKey *FSTTestDocKey(NSString *path) { return [FSTDocumentKey keyWithPathString:path]; } -FSTDocumentKeySet *FSTTestDocKeySet(NSArray *keys) { - FSTDocumentKeySet *result = [FSTDocumentKeySet keySet]; - for (FSTDocumentKey *key in keys) { - result = [result setByAddingObject:key]; - } - return result; -} - FSTDocument *FSTTestDoc(const absl::string_view path, FSTTestSnapshotVersion version, NSDictionary *data, @@ -343,17 +337,17 @@ NSData *_Nullable FSTTestResumeTokenFromSnapshotVersion(FSTTestSnapshotVersion s FSTLocalViewChanges *FSTTestViewChanges(FSTQuery *query, NSArray *addedKeys, NSArray *removedKeys) { - FSTDocumentKeySet *added = [FSTDocumentKeySet keySet]; + DocumentKeySet added; for (NSString *keyPath in addedKeys) { - FSTDocumentKey *key = FSTTestDocKey(keyPath); - added = [added setByAddingObject:key]; + added = added.insert(testutil::Key(util::MakeStringView(keyPath))); } - FSTDocumentKeySet *removed = [FSTDocumentKeySet keySet]; + DocumentKeySet removed; for (NSString *keyPath in removedKeys) { - FSTDocumentKey *key = FSTTestDocKey(keyPath); - removed = [removed setByAddingObject:key]; + removed = removed.insert(testutil::Key(util::MakeStringView(keyPath))); } - return [FSTLocalViewChanges changesForQuery:query addedKeys:added removedKeys:removed]; + return [FSTLocalViewChanges changesForQuery:query + addedKeys:std::move(added) + removedKeys:std::move(removed)]; } NS_ASSUME_NONNULL_END -- cgit v1.2.3