News for hackers. Stuff that matters.
Re:Decreasing the Number of Memory Accesses 1/2 by another2another on Friday March 31, 2023 @07:54AM (#35385663)
I feel the first example for ranges is a bit contrived, most people would end up with something more like:

  void get_ids_adult_users(const std::vector<user_t>& allUsers, std::vector<int>& adultUsers)
  {
      for (const user_t& user: allUsers) {
          if (user.age >= 18) {
              adultUsers.push_back(user.age);
          }
      }
  }

probably after calling reserve() on the adultUsers vector to avoid resizing.

There are no comments on this comment yet.