Skip to content

Commit 8311c64

Browse files
authored
port paths to FSTDocumentKey (firebase#877)
* replace path with C++ implementation in FSTDocumentKey.{h,mm} only * address changes * address changes
1 parent 34ebf10 commit 8311c64

23 files changed

+152
-111
lines changed

Firestore/Example/Tests/Model/FSTDocumentKeyTests.mm

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
#import <XCTest/XCTest.h>
2020

21-
#import "Firestore/Source/Model/FSTPath.h"
21+
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
22+
23+
using firebase::firestore::model::ResourcePath;
2224

2325
NS_ASSUME_NONNULL_BEGIN
2426

@@ -28,23 +30,22 @@ @interface FSTDocumentKeyTests : XCTestCase
2830
@implementation FSTDocumentKeyTests
2931

3032
- (void)testConstructor {
31-
FSTResourcePath *path =
32-
[FSTResourcePath pathWithSegments:@[ @"rooms", @"firestore", @"messages", @"1" ]];
33+
ResourcePath path{"rooms", "firestore", "messages", "1"};
3334
FSTDocumentKey *key = [FSTDocumentKey keyWithPath:path];
3435
XCTAssertEqual(path, key.path);
3536
}
3637

3738
- (void)testComparison {
38-
FSTDocumentKey *key1 = [FSTDocumentKey keyWithSegments:@[ @"a", @"b", @"c", @"d" ]];
39-
FSTDocumentKey *key2 = [FSTDocumentKey keyWithSegments:@[ @"a", @"b", @"c", @"d" ]];
40-
FSTDocumentKey *key3 = [FSTDocumentKey keyWithSegments:@[ @"x", @"y", @"z", @"w" ]];
39+
FSTDocumentKey *key1 = [FSTDocumentKey keyWithSegments:{"a", "b", "c", "d"}];
40+
FSTDocumentKey *key2 = [FSTDocumentKey keyWithSegments:{"a", "b", "c", "d"}];
41+
FSTDocumentKey *key3 = [FSTDocumentKey keyWithSegments:{"x", "y", "z", "w"}];
4142
XCTAssertTrue([key1 isEqualToKey:key2]);
4243
XCTAssertFalse([key1 isEqualToKey:key3]);
4344

44-
FSTDocumentKey *empty = [FSTDocumentKey keyWithSegments:@[]];
45-
FSTDocumentKey *a = [FSTDocumentKey keyWithSegments:@[ @"a", @"a" ]];
46-
FSTDocumentKey *b = [FSTDocumentKey keyWithSegments:@[ @"b", @"b" ]];
47-
FSTDocumentKey *ab = [FSTDocumentKey keyWithSegments:@[ @"a", @"a", @"b", @"b" ]];
45+
FSTDocumentKey *empty = [FSTDocumentKey keyWithSegments:{}];
46+
FSTDocumentKey *a = [FSTDocumentKey keyWithSegments:{"a", "a"}];
47+
FSTDocumentKey *b = [FSTDocumentKey keyWithSegments:{"b", "b"}];
48+
FSTDocumentKey *ab = [FSTDocumentKey keyWithSegments:{"a", "a", "b", "b"}];
4849

4950
XCTAssertEqual(NSOrderedAscending, [empty compare:a]);
5051
XCTAssertEqual(NSOrderedAscending, [a compare:b]);

Firestore/Example/Tests/Util/FSTHelpers.mm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@
4343

4444
#include "Firestore/core/src/firebase/firestore/model/database_id.h"
4545
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
46+
#include "Firestore/core/test/firebase/firestore/testutil/testutil.h"
4647

4748
namespace util = firebase::firestore::util;
49+
namespace testutil = firebase::firestore::testutil;
4850
using firebase::firestore::model::DatabaseId;
4951

5052
NS_ASSUME_NONNULL_BEGIN
@@ -266,7 +268,7 @@ NSComparator FSTTestDocComparator(NSString *fieldPath) {
266268
}
267269
}];
268270

269-
FSTDocumentKey *key = [FSTDocumentKey keyWithPath:FSTTestPath(path)];
271+
FSTDocumentKey *key = [FSTDocumentKey keyWithPath:testutil::Resource([path UTF8String])];
270272
FSTFieldMask *mask = [[FSTFieldMask alloc] initWithFields:merge ? updateMask : fieldMaskPaths];
271273
return [[FSTPatchMutation alloc] initWithKey:key
272274
fieldMask:mask
@@ -277,7 +279,7 @@ NSComparator FSTTestDocComparator(NSString *fieldPath) {
277279
// For now this only creates TransformMutations with server timestamps.
278280
FSTTransformMutation *FSTTestTransformMutation(NSString *path,
279281
NSArray<NSString *> *serverTimestampFields) {
280-
FSTDocumentKey *key = [FSTDocumentKey keyWithPath:FSTTestPath(path)];
282+
FSTDocumentKey *key = [FSTDocumentKey keyWithPath:testutil::Resource([path UTF8String])];
281283
NSMutableArray<FSTFieldTransform *> *fieldTransforms = [NSMutableArray array];
282284
for (NSString *field in serverTimestampFields) {
283285
FSTFieldPath *fieldPath = FSTTestFieldPath(field);

Firestore/Source/API/FIRCollectionReference.mm

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ - (FIRDocumentReference *_Nullable)parent {
101101
if (parentPath.empty()) {
102102
return nil;
103103
} else {
104-
FSTDocumentKey *key =
105-
[FSTDocumentKey keyWithPath:[FSTResourcePath resourcePathWithCPPResourcePath:parentPath]];
104+
FSTDocumentKey *key = [FSTDocumentKey keyWithPath:parentPath];
106105
return [FIRDocumentReference referenceWithKey:key firestore:self.firestore];
107106
}
108107
}
@@ -135,9 +134,7 @@ - (FIRDocumentReference *)addDocumentWithData:(NSDictionary<NSString *, id> *)da
135134
}
136135

137136
- (FIRDocumentReference *)documentWithAutoID {
138-
const ResourcePath path = self.query.path.Append(CreateAutoId());
139-
FSTDocumentKey *key =
140-
[FSTDocumentKey keyWithPath:[FSTResourcePath resourcePathWithCPPResourcePath:path]];
137+
FSTDocumentKey *key = [FSTDocumentKey keyWithPath:self.query.path.Append(CreateAutoId())];
141138
return [FIRDocumentReference referenceWithKey:key firestore:self.firestore];
142139
}
143140

Firestore/Source/API/FIRDocumentReference.mm

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
#import "Firestore/Source/Util/FSTAsyncQueryListener.h"
4040
#import "Firestore/Source/Util/FSTUsageValidation.h"
4141

42+
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
43+
#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
44+
45+
namespace util = firebase::firestore::util;
46+
using firebase::firestore::model::ResourcePath;
47+
4248
NS_ASSUME_NONNULL_BEGIN
4349

4450
#pragma mark - FIRDocumentListenOptions
@@ -93,7 +99,8 @@ + (instancetype)referenceWithPath:(FSTResourcePath *)path firestore:(FIRFirestor
9399
path.canonicalString, path.length);
94100
}
95101
return
96-
[FIRDocumentReference referenceWithKey:[FSTDocumentKey keyWithPath:path] firestore:firestore];
102+
[FIRDocumentReference referenceWithKey:[FSTDocumentKey keyWithPath:[path toCPPResourcePath]]
103+
firestore:firestore];
97104
}
98105

99106
+ (instancetype)referenceWithKey:(FSTDocumentKey *)key firestore:(FIRFirestore *)firestore {
@@ -136,24 +143,26 @@ - (NSUInteger)hash {
136143
#pragma mark - Public Methods
137144

138145
- (NSString *)documentID {
139-
return [self.key.path lastSegment];
146+
return util::WrapNSString(self.key.path.last_segment());
140147
}
141148

142149
- (FIRCollectionReference *)parent {
143-
FSTResourcePath *parentPath = [self.key.path pathByRemovingLastSegment];
144-
return [FIRCollectionReference referenceWithPath:parentPath firestore:self.firestore];
150+
return [FIRCollectionReference
151+
referenceWithPath:[FSTResourcePath resourcePathWithCPPResourcePath:self.key.path.PopLast()]
152+
firestore:self.firestore];
145153
}
146154

147155
- (NSString *)path {
148-
return [self.key.path canonicalString];
156+
return util::WrapNSString(self.key.path.CanonicalString());
149157
}
150158

151159
- (FIRCollectionReference *)collectionWithPath:(NSString *)collectionPath {
152160
if (!collectionPath) {
153161
FSTThrowInvalidArgument(@"Collection path cannot be nil.");
154162
}
155163
FSTResourcePath *subPath = [FSTResourcePath pathWithString:collectionPath];
156-
FSTResourcePath *path = [self.key.path pathByAppendingPath:subPath];
164+
FSTResourcePath *path = [FSTResourcePath
165+
resourcePathWithCPPResourcePath:self.key.path.Append([subPath toCPPResourcePath])];
157166
return [FIRCollectionReference referenceWithPath:path firestore:self.firestore];
158167
}
159168

@@ -266,7 +275,7 @@ - (void)getDocumentWithCompletion:(void (^)(FIRDocumentSnapshot *_Nullable docum
266275
addSnapshotListenerInternalWithOptions:(FSTListenOptions *)internalOptions
267276
listener:(FIRDocumentSnapshotBlock)listener {
268277
FIRFirestore *firestore = self.firestore;
269-
FSTQuery *query = [FSTQuery queryWithPath:[self.key.path toCPPResourcePath]];
278+
FSTQuery *query = [FSTQuery queryWithPath:self.key.path];
270279
FSTDocumentKey *key = self.key;
271280

272281
FSTViewSnapshotHandler snapshotHandler = ^(FSTViewSnapshot *snapshot, NSError *error) {

Firestore/Source/API/FIRDocumentSnapshot.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ - (FIRDocumentReference *)reference {
122122
}
123123

124124
- (NSString *)documentID {
125-
return [self.internalKey.path lastSegment];
125+
return util::WrapNSString(self.internalKey.path.last_segment());
126126
}
127127

128128
- (FIRSnapshotMetadata *)metadata {

Firestore/Source/API/FIRQuery.mm

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,7 @@ - (FIRQuery *)queryWithFilterOperator:(FSTRelationFilterOperator)filterOperator
469469
@"Invalid query. When querying by document ID you must provide "
470470
"a valid document ID, but it was an empty string.");
471471
}
472-
FSTResourcePath *path = [[FSTResourcePath resourcePathWithCPPResourcePath:self.query.path]
473-
pathByAppendingSegment:documentKey];
472+
ResourcePath path = self.query.path.Append([documentKey UTF8String]);
474473
fieldValue = [FSTReferenceValue referenceValue:[FSTDocumentKey keyWithPath:path]
475474
databaseID:self.firestore.databaseID];
476475
} else if ([value isKindOfClass:[FIRDocumentReference class]]) {
@@ -621,10 +620,8 @@ - (FSTBound *)boundFromFieldValues:(NSArray<id> *)fieldValues isBefore:(BOOL)isB
621620
FSTThrowInvalidUsage(@"InvalidQueryException",
622621
@"Invalid query. Document ID '%@' contains a slash.", documentID);
623622
}
624-
FSTDocumentKey *key = [FSTDocumentKey
625-
keyWithPath:[FSTResourcePath
626-
resourcePathWithCPPResourcePath:self.query.path.Append(
627-
[documentID UTF8String])]];
623+
FSTDocumentKey *key =
624+
[FSTDocumentKey keyWithPath:self.query.path.Append([documentID UTF8String])];
628625
[components
629626
addObject:[FSTReferenceValue referenceValue:key databaseID:self.firestore.databaseID]];
630627
} else {

Firestore/Source/Core/FSTQuery.mm

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,7 @@ - (NSArray *)sortOrders {
620620
}
621621

622622
- (instancetype)queryByAddingFilter:(id<FSTFilter>)filter {
623-
FSTAssert(![FSTDocumentKey isDocumentKey:[FSTResourcePath resourcePathWithCPPResourcePath:_path]],
624-
@"No filtering allowed for document query");
623+
FSTAssert(![FSTDocumentKey isDocumentKey:_path], @"No filtering allowed for document query");
625624

626625
const FieldPath *newInequalityField = nullptr;
627626
if ([filter isKindOfClass:[FSTRelationFilter class]] &&
@@ -642,8 +641,7 @@ - (instancetype)queryByAddingFilter:(id<FSTFilter>)filter {
642641
}
643642

644643
- (instancetype)queryByAddingSortOrder:(FSTSortOrder *)sortOrder {
645-
FSTAssert(![FSTDocumentKey isDocumentKey:[FSTResourcePath resourcePathWithCPPResourcePath:_path]],
646-
@"No ordering is allowed for a document query.");
644+
FSTAssert(![FSTDocumentKey isDocumentKey:_path], @"No ordering is allowed for a document query.");
647645

648646
// TODO(klimt): Validate that the same key isn't added twice.
649647
return [[FSTQuery alloc] initWithPath:self.path
@@ -682,8 +680,7 @@ - (instancetype)queryByAddingEndAt:(FSTBound *)bound {
682680
}
683681

684682
- (BOOL)isDocumentQuery {
685-
return [FSTDocumentKey isDocumentKey:[FSTResourcePath resourcePathWithCPPResourcePath:_path]] &&
686-
self.filters.count == 0;
683+
return [FSTDocumentKey isDocumentKey:_path] && self.filters.count == 0;
687684
}
688685

689686
- (BOOL)matchesDocument:(FSTDocument *)document {
@@ -777,14 +774,13 @@ - (BOOL)isEqualToQuery:(FSTQuery *)other {
777774

778775
/* Returns YES if the document matches the path for the receiver. */
779776
- (BOOL)pathMatchesDocument:(FSTDocument *)document {
780-
FSTResourcePath *documentPath = document.key.path;
781-
if ([FSTDocumentKey isDocumentKey:[FSTResourcePath resourcePathWithCPPResourcePath:_path]]) {
777+
const ResourcePath &documentPath = document.key.path;
778+
if ([FSTDocumentKey isDocumentKey:_path]) {
782779
// Exact match for document queries.
783-
return self.path == [documentPath toCPPResourcePath];
780+
return self.path == documentPath;
784781
} else {
785782
// Shallow ancestor queries by default.
786-
return self.path.IsPrefixOf([documentPath toCPPResourcePath]) &&
787-
_path.size() == documentPath.length - 1;
783+
return self.path.IsPrefixOf(documentPath) && _path.size() == documentPath.size() - 1;
788784
}
789785
}
790786

Firestore/Source/Core/FSTSyncEngine.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ - (void)trackLimboChange:(FSTLimboDocumentChange *)limboChange {
497497
if (!self.limboTargetsByKey[key]) {
498498
FSTLog(@"New document in limbo: %@", key);
499499
FSTTargetID limboTargetID = _targetIdGenerator.NextId();
500-
FSTQuery *query = [FSTQuery queryWithPath:[key.path toCPPResourcePath]];
500+
FSTQuery *query = [FSTQuery queryWithPath:key.path];
501501
FSTQueryData *queryData = [[FSTQueryData alloc] initWithQuery:query
502502
targetID:limboTargetID
503503
listenSequenceNumber:kIrrelevantSequenceNumber

Firestore/Source/Local/FSTLevelDBKey.mm

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@
1717
#import "Firestore/Source/Local/FSTLevelDBKey.h"
1818

1919
#include <string>
20+
#include <utility>
21+
#include <vector>
2022

2123
#import "Firestore/Source/Model/FSTDocumentKey.h"
2224
#import "Firestore/Source/Model/FSTPath.h"
2325

26+
#include "Firestore/core/src/firebase/firestore/model/resource_path.h"
2427
#include "Firestore/core/src/firebase/firestore/util/ordered_code.h"
2528

29+
namespace util = firebase::firestore::util;
30+
using firebase::firestore::model::ResourcePath;
31+
2632
NS_ASSUME_NONNULL_BEGIN
2733

2834
using firebase::firestore::util::OrderedCode;
@@ -271,7 +277,7 @@ BOOL ReadDocumentKey(Slice *contents, FSTDocumentKey *__strong *result) {
271277
Slice completeSegments = *contents;
272278

273279
std::string segment;
274-
NSMutableArray<NSString *> *pathSegments = [NSMutableArray array];
280+
std::vector<std::string> path_segments{};
275281
for (;;) {
276282
// Advance a temporary slice to avoid advancing contents into the next key component which may
277283
// not be a path segment.
@@ -283,15 +289,14 @@ BOOL ReadDocumentKey(Slice *contents, FSTDocumentKey *__strong *result) {
283289
return NO;
284290
}
285291

286-
NSString *pathSegment = [[NSString alloc] initWithUTF8String:segment.c_str()];
287-
[pathSegments addObject:pathSegment];
292+
path_segments.push_back(std::move(segment));
288293
segment.clear();
289294

290295
completeSegments = leveldb::Slice(readPosition.data(), readPosition.size());
291296
}
292297

293-
FSTResourcePath *path = [FSTResourcePath pathWithSegments:pathSegments];
294-
if (path.length > 0 && [FSTDocumentKey isDocumentKey:path]) {
298+
ResourcePath path{std::move(path_segments)};
299+
if (path.size() > 0 && [FSTDocumentKey isDocumentKey:path]) {
295300
*contents = completeSegments;
296301
*result = [FSTDocumentKey keyWithPath:path];
297302
return YES;
@@ -391,7 +396,7 @@ + (NSString *)descriptionForKey:(StringView)key {
391396
if (!ReadDocumentKey(&tmp, &documentKey)) {
392397
break;
393398
}
394-
[description appendFormat:@" key=%@", [documentKey.path description]];
399+
[description appendFormat:@" key=%s", documentKey.path.CanonicalString().c_str()];
395400

396401
} else if (label == FSTComponentLabelTableName) {
397402
std::string table;
@@ -531,7 +536,7 @@ @implementation FSTLevelDBDocumentMutationKey {
531536
std::string result;
532537
WriteTableName(&result, kDocumentMutationsTable);
533538
WriteUserID(&result, userID);
534-
WriteResourcePath(&result, documentKey.path);
539+
WriteResourcePath(&result, [FSTResourcePath resourcePathWithCPPResourcePath:documentKey.path]);
535540
WriteBatchID(&result, batchID);
536541
WriteTerminator(&result);
537542
return result;
@@ -685,7 +690,7 @@ @implementation FSTLevelDBTargetDocumentKey
685690
std::string result;
686691
WriteTableName(&result, kTargetDocumentsTable);
687692
WriteTargetID(&result, targetID);
688-
WriteResourcePath(&result, documentKey.path);
693+
WriteResourcePath(&result, [FSTResourcePath resourcePathWithCPPResourcePath:documentKey.path]);
689694
WriteTerminator(&result);
690695
return result;
691696
}
@@ -719,7 +724,7 @@ @implementation FSTLevelDBDocumentTargetKey
719724
+ (std::string)keyWithDocumentKey:(FSTDocumentKey *)documentKey targetID:(FSTTargetID)targetID {
720725
std::string result;
721726
WriteTableName(&result, kDocumentTargetsTable);
722-
WriteResourcePath(&result, documentKey.path);
727+
WriteResourcePath(&result, [FSTResourcePath resourcePathWithCPPResourcePath:documentKey.path]);
723728
WriteTargetID(&result, targetID);
724729
WriteTerminator(&result);
725730
return result;
@@ -754,7 +759,7 @@ @implementation FSTLevelDBRemoteDocumentKey
754759
+ (std::string)keyWithDocumentKey:(FSTDocumentKey *)key {
755760
std::string result;
756761
WriteTableName(&result, kRemoteDocumentsTable);
757-
WriteResourcePath(&result, key.path);
762+
WriteResourcePath(&result, [FSTResourcePath resourcePathWithCPPResourcePath:key.path]);
758763
WriteTerminator(&result);
759764
return result;
760765
}

Firestore/Source/Local/FSTLevelDBMutationQueue.mm

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,9 @@ - (nullable FSTMutationBatch *)nextMutationBatchAfterBatchID:(FSTBatchID)batchID
375375
NSString *userID = self.userID;
376376

377377
// Scan the document-mutation index starting with a prefix starting with the given documentKey.
378-
std::string indexPrefix =
379-
[FSTLevelDBDocumentMutationKey keyPrefixWithUserID:self.userID resourcePath:documentKey.path];
378+
std::string indexPrefix = [FSTLevelDBDocumentMutationKey
379+
keyPrefixWithUserID:self.userID
380+
resourcePath:[FSTResourcePath resourcePathWithCPPResourcePath:documentKey.path]];
380381
std::unique_ptr<Iterator> indexIterator(_db->NewIterator(StandardReadOptions()));
381382
indexIterator->Seek(indexPrefix);
382383

@@ -467,7 +468,7 @@ - (nullable FSTMutationBatch *)nextMutationBatchAfterBatchID:(FSTBatchID)batchID
467468
// Rows with document keys more than one segment longer than the query path can't be matches.
468469
// For example, a query on 'rooms' can't match the document /rooms/abc/messages/xyx.
469470
// TODO(mcg): we'll need a different scanner when we implement ancestor queries.
470-
if (rowKey.documentKey.path.length != immediateChildrenPathLength) {
471+
if (rowKey.documentKey.path.size() != immediateChildrenPathLength) {
471472
continue;
472473
}
473474

@@ -614,8 +615,9 @@ - (FSTMutationBatch *)decodedMutationBatch:(Slice)slice {
614615
#pragma mark - FSTGarbageSource implementation
615616

616617
- (BOOL)containsKey:(FSTDocumentKey *)documentKey {
617-
std::string indexPrefix =
618-
[FSTLevelDBDocumentMutationKey keyPrefixWithUserID:self.userID resourcePath:documentKey.path];
618+
std::string indexPrefix = [FSTLevelDBDocumentMutationKey
619+
keyPrefixWithUserID:self.userID
620+
resourcePath:[FSTResourcePath resourcePathWithCPPResourcePath:documentKey.path]];
619621
std::unique_ptr<Iterator> indexIterator(_db->NewIterator(StandardReadOptions()));
620622
indexIterator->Seek(indexPrefix);
621623

Firestore/Source/Local/FSTLevelDBQueryCache.mm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#import "Firestore/Source/Local/FSTQueryData.h"
2828
#import "Firestore/Source/Local/FSTWriteGroup.h"
2929
#import "Firestore/Source/Model/FSTDocumentKey.h"
30+
#import "Firestore/Source/Model/FSTPath.h"
3031
#import "Firestore/Source/Util/FSTAssert.h"
3132

3233
NS_ASSUME_NONNULL_BEGIN
@@ -339,7 +340,8 @@ - (FSTDocumentKeySet *)matchingKeysForTargetID:(FSTTargetID)targetID {
339340
#pragma mark - FSTGarbageSource implementation
340341

341342
- (BOOL)containsKey:(FSTDocumentKey *)key {
342-
std::string indexPrefix = [FSTLevelDBDocumentTargetKey keyPrefixWithResourcePath:key.path];
343+
std::string indexPrefix = [FSTLevelDBDocumentTargetKey
344+
keyPrefixWithResourcePath:[FSTResourcePath resourcePathWithCPPResourcePath:key.path]];
343345
std::unique_ptr<Iterator> indexIterator(_db->NewIterator([FSTLevelDB standardReadOptions]));
344346
indexIterator->Seek(indexPrefix);
345347

Firestore/Source/Local/FSTLevelDBRemoteDocumentCache.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ - (FSTDocumentDictionary *)documentsMatchingQuery:(FSTQuery *)query {
113113
for (; it->Valid() && [currentKey decodeKey:it->key()]; it->Next()) {
114114
FSTMaybeDocument *maybeDoc =
115115
[self decodedMaybeDocument:it->value() withKey:currentKey.documentKey];
116-
if (!query.path.IsPrefixOf([maybeDoc.key.path toCPPResourcePath])) {
116+
if (!query.path.IsPrefixOf(maybeDoc.key.path)) {
117117
break;
118118
} else if ([maybeDoc isKindOfClass:[FSTDocument class]]) {
119119
results = [results dictionaryBySettingObject:(FSTDocument *)maybeDoc forKey:maybeDoc.key];

0 commit comments

Comments
 (0)