| 1331 | namespace { |
| 1332 | |
| 1333 | std::unordered_multimap<std::string_view, int> CreateNameToIndexMap( |
| 1334 | const FieldVector& fields) { |
| 1335 | std::unordered_multimap<std::string_view, int> name_to_index; |
| 1336 | name_to_index.reserve(fields.size()); |
| 1337 | for (size_t i = 0; i < fields.size(); ++i) { |
| 1338 | const std::string_view name = fields[i]->name(); |
| 1339 | // The find() hint avoids libc++'s quadratic scan of equal keys on plain emplace. |
| 1340 | name_to_index.emplace_hint(name_to_index.find(name), name, static_cast<int>(i)); |
| 1341 | } |
| 1342 | return name_to_index; |
| 1343 | } |
| 1344 | |
| 1345 | template <int NotFoundValue = -1, int DuplicateFoundValue = -1> |
| 1346 | int LookupNameIndex(const std::unordered_multimap<std::string_view, int>& name_to_index, |