From 6ab0195f11e9a0daab46babf7f894bb08b2ae9c3 Mon Sep 17 00:00:00 2001 From: Konstantin Varlamov Date: Mon, 16 Jul 2018 18:20:00 -0400 Subject: Minimize rereading of batches in FSTLocalDocumentsView documentsMatchingCollectionQuery (#1533) Previously in `documentsMatchingCollectionQuery`, write batches were read three times; in fact, all relevant batches will always be contained inside `allMutationBatchesAffectingQuery` (which is also more efficient); the other two calls were redundant. --- Firestore/core/src/firebase/firestore/model/base_path.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Firestore/core/src/firebase') diff --git a/Firestore/core/src/firebase/firestore/model/base_path.h b/Firestore/core/src/firebase/firestore/model/base_path.h index 7608829..31aaebb 100644 --- a/Firestore/core/src/firebase/firestore/model/base_path.h +++ b/Firestore/core/src/firebase/firestore/model/base_path.h @@ -139,6 +139,16 @@ class BasePath { return size() <= rhs.size() && std::equal(begin(), end(), rhs.begin()); } + /** + * Returns true if the given argument is a direct child of this path. + * + * Empty path is a parent of any path that consists of a single segment. + */ + bool IsImmediateParentOf(const T& potential_child) const { + return size() + 1 == potential_child.size() && + std::equal(begin(), end(), potential_child.begin()); + } + bool operator==(const BasePath& rhs) const { return segments_ == rhs.segments_; } -- cgit v1.2.3