Skip to content

Commit dbd232f

Browse files
committed
isValidId function and pass const to vectorContains
1 parent cf8e699 commit dbd232f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ear-production-suite-plugins/lib/src/binaural_monitoring_backend.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ using std::placeholders::_2;
1010

1111
namespace {
1212
template<typename T>
13-
bool vectorContains(std::vector<T> &v, T k) {
13+
bool vectorContains(std::vector<T> const& v, T k) {
1414
return std::find(v.begin(), v.end(), k) != v.end();
1515
}
16+
17+
bool isValidId(std::string const& id) {
18+
return !(id.empty() || id == "00000000-0000-0000-0000-000000000000");
19+
}
1620
}
1721

1822
namespace ear {
@@ -212,8 +216,7 @@ void BinauralMonitoringBackend::onSceneReceived(proto::SceneStore store) {
212216

213217
for (const auto& item : store.all_available_items()) {
214218
if(item.has_connection_id() &&
215-
item.connection_id() != "00000000-0000-0000-0000-000000000000" &&
216-
item.connection_id() != "") {
219+
isValidId(item.connection_id())) {
217220
availableItemIds.push_back(item.connection_id());
218221
}
219222
if (item.has_ds_metadata()) {
@@ -246,8 +249,7 @@ void BinauralMonitoringBackend::onSceneReceived(proto::SceneStore store) {
246249

247250
for (const auto& item : store.monitoring_items()) {
248251
if (item.has_connection_id() &&
249-
item.connection_id() != "00000000-0000-0000-0000-000000000000" &&
250-
item.connection_id() != "" &&
252+
isValidId(item.connection_id()) &&
251253
vectorContains(availableItemIds, item.connection_id())) {
252254

253255
bool newItem = !vectorContains(allActiveIds, item.connection_id());

0 commit comments

Comments
 (0)