예제 #1
0
int
IPv4Socket::poll_(pollfd* pfd,
                  nfds_t nfd,
                  const boost::optional<bc::milliseconds>& timeout)
{
    const int t = timeout ? timeout->count() : -1;
    return rs_poll(pfd, nfd, t);
}
예제 #2
0
size_t dedup_methods_helper(
    const Scope& scope,
    const std::vector<DexMethod*>& to_dedup,
    std::vector<DexMethod*>& replacements,
    boost::optional<std::unordered_map<DexMethod*, MethodOrderedSet>>&
        new_to_old) {
  if (to_dedup.size() <= 1) {
    replacements = to_dedup;
    return 0;
  }
  size_t dedup_count = 0;
  auto grouped_methods = group_identical_methods(to_dedup);
  std::unordered_map<DexMethod*, DexMethod*> duplicates_to_replacement;
  for (auto& group : grouped_methods) {
    auto replacement = *group.begin();
    for (auto m : group) {
      duplicates_to_replacement[m] = replacement;
      // Update dedup map
      if (new_to_old == boost::none) {
        continue;
      }
      if (new_to_old->count(m) > 0) {
        auto orig_old_list = new_to_old->at(m);
        new_to_old->erase(m);
        for (auto orig_old : orig_old_list) {
          new_to_old.get()[replacement].insert(orig_old);
        }
      }
      new_to_old.get()[replacement].insert(m);
    }
    if (new_to_old != boost::none) {
      new_to_old.get()[replacement].insert(replacement);
    }

    replacements.push_back(replacement);
    if (group.size() > 1) {
      dedup_count += group.size() - 1;
      TRACE(METH_DEDUP,
            9,
            "dedup: group %d replacement %s\n",
            group.size(),
            SHOW(replacement));
    }
  }
  method_reference::update_call_refs_simple(scope, duplicates_to_replacement);
  return dedup_count;
}