int Remove(AppControlAction* h) {
std::lock_guard<std::recursive_mutex> lock(GetMutex());
- auto found =
- std::find_if(actions_.begin(), actions_.end(),
- [h](const auto& action) { return action.get() == h; });
- if (found == actions_.end()) {
- _E("Failed to find action(%p)", h);
- return -EINVAL;
+ auto iter = actions_.begin();
+ while (iter != actions_.end()) {
+ if (iter->get() == h) {
+ iter = actions_.erase(iter);
+ break;
+ }
+
+ iter++;
}
-
- actions_.erase(found);
return 0;
}
if (info == nullptr) return nullptr;
// Step 1
- auto found =
- std::find_if(infos_.begin(), infos_.end(),
- [&info](const std::shared_ptr<AppControlInfo>& a_info) {
- return a_info->Match(*info);
- });
- if (found != infos_.end()) return *found;
+ for (auto& a_info : infos_) {
+ if (a_info->Match(*info)) return a_info;
+ }
// Step 2
if (info->GetUriScheme() != "NULL" && info->GetUriHost() != "NULL") {
info->SetUri(info->GetUriScheme() + "://" + info->GetUriHost());
- found = std::find_if(
- infos_.begin(), infos_.end(),
- [&info](const auto& a_info) { return a_info->Match(*info); });
- if (found != infos_.end()) return *found;
+ for (auto& a_info : infos_) {
+ if (a_info->Match(*info)) return a_info;
+ }
}
// Step 3
info->SetUri(info->GetUriScheme());
- found = std::find_if(
- infos_.begin(), infos_.end(),
- [&info](const auto& a_info) { return a_info->Match(*info); });
- if (found != infos_.end()) return *found;
+ for (auto& a_info : infos_) {
+ if (a_info->Match(*info)) return a_info;
+ }
// Step 4
info->SetUri("*");
- found = std::find_if(
- infos_.begin(), infos_.end(),
- [&info](const auto& a_info) { return a_info->Match(*info); });
- if (found != infos_.end()) return *found;
+ for (auto& a_info : infos_) {
+ if (a_info->Match(*info)) return a_info;
+ }
// Step 5
- if (info->GetUriScheme() == "file" && info->GetMime() != "NULL") {
+ if (info->GetUriScheme() == "file" && info->GetMime() != "NULL") {
info->SetUri("NULL");
- found = std::find_if(
- infos_.begin(), infos_.end(),
- [&info](const auto& a_info) { return a_info->Match(*info); });
- if (found != infos_.end()) return *found;
+ for (auto& a_info : infos_) {
+ if (a_info->Match(*info)) return a_info;
+ }
}
return nullptr;