arvidjonasson commented on issue #48977:
URL: https://github.com/apache/arrow/issues/48977#issuecomment-3798909735

   > Can we improve performance by the following like the change in 
https://bugs.llvm.org/show_bug.cgi?id=16747#c2 ?
   
   Probably yes, however I think the greatest improvement from that thread was 
done by changing `map.insert({i % 4, i})` to `map.insert(map.find(i % 4), {i % 
4, i})`. That will according to the libc++ maintainer insert elements at the 
beginning of equal ranges instead of linearly searching for the end of them.
   
   Since we are using `emplace` we'd need `emplace_hint` to get the same effect:
   ```diff
    std::unordered_multimap<std::string_view, int> CreateNameToIndexMap(
        const FieldVector& fields) {
      std::unordered_multimap<std::string_view, int> name_to_index;
      for (size_t i = 0; i < fields.size(); ++i) {
   -    name_to_index.emplace(fields[i]->name(), static_cast<int>(i));
   +    name_to_index.emplace_hint(name_to_index.find(fields[i]->name()), 
fields[i]->name(), static_cast<int>(i));
      }
      return name_to_index;
    }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to