Statsd cpu optimizaton

- cache the changed dimensions in condition tracker.
- avoid query condition wizard when unnecessary.
- avoid copy dimension keys in condition key generation.

Test: statsd tests.

BUG: b/73959649
Change-Id: I17d68e2a82643de3f421309841e75f84c6fd8f43
diff --git a/cmds/statsd/src/FieldValue.cpp b/cmds/statsd/src/FieldValue.cpp
index b541612..0c9b701 100644
--- a/cmds/statsd/src/FieldValue.cpp
+++ b/cmds/statsd/src/FieldValue.cpp
@@ -205,6 +205,29 @@
     }
 }
 
+bool equalDimensions(const std::vector<Matcher>& dimension_a,
+                     const std::vector<Matcher>& dimension_b) {
+    bool eq = dimension_a.size() == dimension_b.size();
+    for (size_t i = 0; eq && i < dimension_a.size(); ++i) {
+        if (dimension_b[i] != dimension_a[i]) {
+            eq = false;
+        }
+    }
+    return eq;
+}
+
+bool HasPositionANY(const FieldMatcher& matcher) {
+    if (matcher.has_position() && matcher.position() == Position::ANY) {
+        return true;
+    }
+    for (const auto& child : matcher.child()) {
+        if (HasPositionANY(child)) {
+            return true;
+        }
+    }
+    return false;
+}
+
 }  // namespace statsd
 }  // namespace os
 }  // namespace android
\ No newline at end of file