From d5c4ad2f8b7f2a1e135d8cb95287bf2a15a9d453 Mon Sep 17 00:00:00 2001 From: cherylEnkidu Date: Wed, 30 Aug 2023 18:35:29 -0400 Subject: [PATCH] Add const for target index matcher --- Firestore/core/src/model/target_index_matcher.cc | 14 ++++++++------ Firestore/core/src/model/target_index_matcher.h | 12 ++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Firestore/core/src/model/target_index_matcher.cc b/Firestore/core/src/model/target_index_matcher.cc index 82e7a93c72e..b26114f0f79 100644 --- a/Firestore/core/src/model/target_index_matcher.cc +++ b/Firestore/core/src/model/target_index_matcher.cc @@ -51,7 +51,7 @@ TargetIndexMatcher::TargetIndexMatcher(const core::Target& target) { } } -bool TargetIndexMatcher::ServedByIndex(const model::FieldIndex& index) { +bool TargetIndexMatcher::ServedByIndex(const model::FieldIndex& index) const { HARD_ASSERT(index.collection_group() == collection_id_, "Collection IDs do not match"); @@ -118,7 +118,7 @@ bool TargetIndexMatcher::ServedByIndex(const model::FieldIndex& index) { return true; } -model::FieldIndex TargetIndexMatcher::BuildTargetIndex() { +model::FieldIndex TargetIndexMatcher::BuildTargetIndex() const { // We want to make sure only one segment created for one field. For example, // in case like a == 3 and a > 2, Index: {a ASCENDING} will only be created // once. @@ -175,7 +175,8 @@ model::FieldIndex TargetIndexMatcher::BuildTargetIndex() { std::move(segments), FieldIndex::InitialState()); } -bool TargetIndexMatcher::HasMatchingEqualityFilter(const Segment& segment) { +bool TargetIndexMatcher::HasMatchingEqualityFilter( + const Segment& segment) const { for (const auto& filter : equality_filters_) { if (MatchesFilter(filter, segment)) { return true; @@ -185,7 +186,8 @@ bool TargetIndexMatcher::HasMatchingEqualityFilter(const Segment& segment) { } bool TargetIndexMatcher::MatchesFilter( - const absl::optional& filter, const Segment& segment) { + const absl::optional& filter, + const Segment& segment) const { if (!filter.has_value()) { return false; } @@ -193,7 +195,7 @@ bool TargetIndexMatcher::MatchesFilter( } bool TargetIndexMatcher::MatchesFilter(const FieldFilter& filter, - const Segment& segment) { + const Segment& segment) const { if (filter.field() != segment.field_path()) { return false; } @@ -204,7 +206,7 @@ bool TargetIndexMatcher::MatchesFilter(const FieldFilter& filter, } bool TargetIndexMatcher::MatchesOrderBy(const OrderBy& order_by, - const Segment& segment) { + const Segment& segment) const { if (order_by.field() != segment.field_path()) { return false; } diff --git a/Firestore/core/src/model/target_index_matcher.h b/Firestore/core/src/model/target_index_matcher.h index 669ba0c4f7d..7afedb43af2 100644 --- a/Firestore/core/src/model/target_index_matcher.h +++ b/Firestore/core/src/model/target_index_matcher.h @@ -75,21 +75,21 @@ class TargetIndexMatcher { * clauses cannot be skipped, but a continuous OrderBy suffix may be * omitted. */ - bool ServedByIndex(const model::FieldIndex& index); + bool ServedByIndex(const model::FieldIndex& index) const; /** Returns a full matched field index for this target. */ - model::FieldIndex BuildTargetIndex(); + model::FieldIndex BuildTargetIndex() const; private: - bool HasMatchingEqualityFilter(const model::Segment& segment); + bool HasMatchingEqualityFilter(const model::Segment& segment) const; bool MatchesFilter(const core::FieldFilter& filter, - const model::Segment& segment); + const model::Segment& segment) const; bool MatchesFilter(const absl::optional& filter, - const model::Segment& segment); + const model::Segment& segment) const; bool MatchesOrderBy(const core::OrderBy& order_by, - const model::Segment& segment); + const model::Segment& segment) const; // The collection ID (or collection group) of the query target. std::string collection_id_;