summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTej Singh <singhtejinder@google.com>2022-04-22 23:11:07 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2022-04-22 23:11:07 +0000
commitd3f31a9fa36fc8ed77f633abcdbe10f8683903d1 (patch)
tree4321c7bb327a6a92907499a98fdd3143dfb25759
parent213186c87b645a44924264150b65ccd9546d1197 (diff)
parentedcdfa85c27c1064fa0e7b27757fb14bf4b95743 (diff)
downloadStatsD-d3f31a9fa36fc8ed77f633abcdbe10f8683903d1.tar.gz
Merge "Use permanent cache for EventMatcherWizard"
-rw-r--r--statsd/src/matchers/EventMatcherWizard.cpp6
-rw-r--r--statsd/src/matchers/EventMatcherWizard.h4
2 files changed, 6 insertions, 4 deletions
diff --git a/statsd/src/matchers/EventMatcherWizard.cpp b/statsd/src/matchers/EventMatcherWizard.cpp
index 025c9a87..30a40a33 100644
--- a/statsd/src/matchers/EventMatcherWizard.cpp
+++ b/statsd/src/matchers/EventMatcherWizard.cpp
@@ -25,9 +25,9 @@ MatchingState EventMatcherWizard::matchLogEvent(const LogEvent& event, int match
if (matcher_index < 0 || matcher_index >= (int)mAllEventMatchers.size()) {
return MatchingState::kNotComputed;
}
- vector<MatchingState> matcherCache(mAllEventMatchers.size(), MatchingState::kNotComputed);
- mAllEventMatchers[matcher_index]->onLogEvent(event, mAllEventMatchers, matcherCache);
- return matcherCache[matcher_index];
+ std::fill(mMatcherCache.begin(), mMatcherCache.end(), MatchingState::kNotComputed);
+ mAllEventMatchers[matcher_index]->onLogEvent(event, mAllEventMatchers, mMatcherCache);
+ return mMatcherCache[matcher_index];
}
} // namespace statsd
diff --git a/statsd/src/matchers/EventMatcherWizard.h b/statsd/src/matchers/EventMatcherWizard.h
index d346b5f5..7bd4529c 100644
--- a/statsd/src/matchers/EventMatcherWizard.h
+++ b/statsd/src/matchers/EventMatcherWizard.h
@@ -26,7 +26,8 @@ class EventMatcherWizard : public virtual RefBase {
public:
EventMatcherWizard(){}; // for testing
EventMatcherWizard(const std::vector<sp<AtomMatchingTracker>>& eventTrackers)
- : mAllEventMatchers(eventTrackers){};
+ : mAllEventMatchers(eventTrackers),
+ mMatcherCache(eventTrackers.size(), MatchingState::kNotComputed){};
virtual ~EventMatcherWizard(){};
@@ -34,6 +35,7 @@ public:
private:
std::vector<sp<AtomMatchingTracker>> mAllEventMatchers;
+ std::vector<MatchingState> mMatcherCache;
};
} // namespace statsd