Add SourceNodeIndex to compute the source node per channel
We keep doing this type of thing. Time to go write a function. Doing a
bunch of string compares is slow, so we should really cache it up front.
It feels like it might be getting close to time to try to write a class
which will let us compute and cache all these things reasonably
efficiently and move logger and others over to it. Let's start with a
function to compute the things we care about.
Change-Id: I4b788b1395656e8e6e6c3c7eb28f4d410080c636
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/configuration.cc b/aos/configuration.cc
index c2e42c9..d794a37 100644
--- a/aos/configuration.cc
+++ b/aos/configuration.cc
@@ -1261,5 +1261,18 @@
return nullptr;
}
+std::vector<size_t> SourceNodeIndex(const Configuration *config) {
+ CHECK(config->has_channels());
+ std::vector<size_t> result;
+ result.resize(config->channels()->size(), 0u);
+ if (MultiNode(config)) {
+ for (size_t i = 0; i < config->channels()->size(); ++i) {
+ result[i] = GetNodeIndex(
+ config, config->channels()->Get(i)->source_node()->string_view());
+ }
+ }
+ return result;
+}
+
} // namespace configuration
} // namespace aos