Merge "Do not use std::vector in android_namespace_t::is_accessible"
diff --git a/linker/linker_namespaces.cpp b/linker/linker_namespaces.cpp
index a7e14cc..273ff9b 100644
--- a/linker/linker_namespaces.cpp
+++ b/linker/linker_namespaces.cpp
@@ -30,8 +30,6 @@
#include "linker_soinfo.h"
#include "linker_utils.h"
-#include <vector>
-
bool android_namespace_t::is_accessible(const std::string& file) {
if (!is_isolated_) {
return true;
@@ -59,13 +57,7 @@
}
bool android_namespace_t::is_accessible(soinfo* s) {
- std::vector<soinfo*> soinfos;
- soinfos.push_back(s);
- s->get_parents().for_each([&](soinfo* parent_si) {
- soinfos.push_back(parent_si);
- });
-
- return std::find_if(soinfos.begin(), soinfos.end(), [this](soinfo* si) {
+ auto is_accessible_ftor = [this] (soinfo* si) {
if (si->get_primary_namespace() == this) {
return true;
}
@@ -76,5 +68,13 @@
}
return false;
- }) != soinfos.end();
+ };
+
+ if (is_accessible_ftor(s)) {
+ return true;
+ }
+
+ return !s->get_parents().visit([&](soinfo* si) {
+ return !is_accessible_ftor(si);
+ });
}