23
23
#import " Firestore/Source/API/FIRDocumentReference+Internal.h"
24
24
#import " Firestore/Source/API/FIRFirestore+Internal.h"
25
25
#import " Firestore/Source/API/FIRQuery+Internal.h"
26
- #import " Firestore/Source/API/FIRQuery_Init.h"
27
26
#import " Firestore/Source/Core/FSTQuery.h"
28
27
29
28
#include " Firestore/core/src/firebase/firestore/api/input_validation.h"
30
29
#include " Firestore/core/src/firebase/firestore/model/document_key.h"
31
30
#include " Firestore/core/src/firebase/firestore/model/resource_path.h"
31
+ #include " Firestore/core/src/firebase/firestore/util/hashing.h"
32
32
#include " Firestore/core/src/firebase/firestore/util/string_apple.h"
33
33
34
34
namespace util = firebase::firestore::util;
@@ -44,9 +44,7 @@ - (instancetype)initWithPath:(const ResourcePath &)path
44
44
firestore : (FIRFirestore *)firestore NS_DESIGNATED_INITIALIZER;
45
45
46
46
// Mark the super class designated initializer unavailable.
47
- - (instancetype )initWithQuery : (FSTQuery *)query
48
- firestore : (FIRFirestore *)firestore
49
- __attribute__((unavailable(" Use the initWithPath constructor of FIRCollectionReference." )));
47
+ - (instancetype )initWithQuery : (api::Query &&)query NS_UNAVAILABLE;
50
48
@end
51
49
52
50
@implementation FIRCollectionReference (Internal)
@@ -63,12 +61,14 @@ - (instancetype)initWithPath:(const ResourcePath &)path firestore:(FIRFirestore
63
61
" number of segments, but %s has %s" ,
64
62
path.CanonicalString (), path.size ());
65
63
}
66
- self = [super initWithQuery: [FSTQuery queryWithPath: path] firestore: firestore];
64
+
65
+ api::Query query ([FSTQuery queryWithPath: path], firestore.wrapped );
66
+ self = [super initWithQuery: std: :move (query)];
67
67
return self;
68
68
}
69
69
70
70
// Override the designated initializer from the super class.
71
- - (instancetype )initWithQuery : (FSTQuery *) query firestore : (FIRFirestore *) firestore {
71
+ - (instancetype )initWithQuery : (api::Query &&) query {
72
72
HARD_FAIL (" Use FIRCollectionReference initWithPath: initializer." );
73
73
}
74
74
@@ -87,9 +87,7 @@ - (BOOL)isEqualToReference:(nullable FIRCollectionReference *)reference {
87
87
}
88
88
89
89
- (NSUInteger )hash {
90
- NSUInteger hash = [self .firestore hash ];
91
- hash = hash * 31u + [self .query hash ];
92
- return hash;
90
+ return util::Hash (self.firestore , self.query );
93
91
}
94
92
95
93
- (NSString *)collectionID {
0 commit comments