diff options
author | zxu <zxu@google.com> | 2018-03-06 14:28:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-06 14:28:04 -0500 |
commit | 8311c6432ecff78bedd13e27f64d241659324786 (patch) | |
tree | 982484ba69cf17172ee4e1308254a0b76894b7d5 /Firestore/Source/Core | |
parent | 34ebf10b0acc65f1924d723e82085d4104bc281d (diff) |
port paths to FSTDocumentKey (#877)
* replace path with C++ implementation in FSTDocumentKey.{h,mm} only
* address changes
* address changes
Diffstat (limited to 'Firestore/Source/Core')
-rw-r--r-- | Firestore/Source/Core/FSTQuery.mm | 18 | ||||
-rw-r--r-- | Firestore/Source/Core/FSTSyncEngine.mm | 2 |
2 files changed, 8 insertions, 12 deletions
diff --git a/Firestore/Source/Core/FSTQuery.mm b/Firestore/Source/Core/FSTQuery.mm index 7314ce9..c10b94d 100644 --- a/Firestore/Source/Core/FSTQuery.mm +++ b/Firestore/Source/Core/FSTQuery.mm @@ -620,8 +620,7 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe } - (instancetype)queryByAddingFilter:(id<FSTFilter>)filter { - FSTAssert(![FSTDocumentKey isDocumentKey:[FSTResourcePath resourcePathWithCPPResourcePath:_path]], - @"No filtering allowed for document query"); + FSTAssert(![FSTDocumentKey isDocumentKey:_path], @"No filtering allowed for document query"); const FieldPath *newInequalityField = nullptr; if ([filter isKindOfClass:[FSTRelationFilter class]] && @@ -642,8 +641,7 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe } - (instancetype)queryByAddingSortOrder:(FSTSortOrder *)sortOrder { - FSTAssert(![FSTDocumentKey isDocumentKey:[FSTResourcePath resourcePathWithCPPResourcePath:_path]], - @"No ordering is allowed for a document query."); + FSTAssert(![FSTDocumentKey isDocumentKey:_path], @"No ordering is allowed for a document query."); // TODO(klimt): Validate that the same key isn't added twice. return [[FSTQuery alloc] initWithPath:self.path @@ -682,8 +680,7 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe } - (BOOL)isDocumentQuery { - return [FSTDocumentKey isDocumentKey:[FSTResourcePath resourcePathWithCPPResourcePath:_path]] && - self.filters.count == 0; + return [FSTDocumentKey isDocumentKey:_path] && self.filters.count == 0; } - (BOOL)matchesDocument:(FSTDocument *)document { @@ -777,14 +774,13 @@ NSString *FSTStringFromQueryRelationOperator(FSTRelationFilterOperator filterOpe /* Returns YES if the document matches the path for the receiver. */ - (BOOL)pathMatchesDocument:(FSTDocument *)document { - FSTResourcePath *documentPath = document.key.path; - if ([FSTDocumentKey isDocumentKey:[FSTResourcePath resourcePathWithCPPResourcePath:_path]]) { + const ResourcePath &documentPath = document.key.path; + if ([FSTDocumentKey isDocumentKey:_path]) { // Exact match for document queries. - return self.path == [documentPath toCPPResourcePath]; + return self.path == documentPath; } else { // Shallow ancestor queries by default. - return self.path.IsPrefixOf([documentPath toCPPResourcePath]) && - _path.size() == documentPath.length - 1; + return self.path.IsPrefixOf(documentPath) && _path.size() == documentPath.size() - 1; } } diff --git a/Firestore/Source/Core/FSTSyncEngine.mm b/Firestore/Source/Core/FSTSyncEngine.mm index 88be23c..a857f5a 100644 --- a/Firestore/Source/Core/FSTSyncEngine.mm +++ b/Firestore/Source/Core/FSTSyncEngine.mm @@ -497,7 +497,7 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1; if (!self.limboTargetsByKey[key]) { FSTLog(@"New document in limbo: %@", key); FSTTargetID limboTargetID = _targetIdGenerator.NextId(); - FSTQuery *query = [FSTQuery queryWithPath:[key.path toCPPResourcePath]]; + FSTQuery *query = [FSTQuery queryWithPath:key.path]; FSTQueryData *queryData = [[FSTQueryData alloc] initWithQuery:query targetID:limboTargetID listenSequenceNumber:kIrrelevantSequenceNumber |