| 1341 | |
| 1342 | template <int NotFoundValue = -1, int DuplicateFoundValue = -1> |
| 1343 | int LookupNameIndex(const std::unordered_multimap<std::string_view, int>& name_to_index, |
| 1344 | std::string_view name) { |
| 1345 | auto p = name_to_index.equal_range(name); |
| 1346 | auto it = p.first; |
| 1347 | if (it == p.second) { |
| 1348 | // Not found |
| 1349 | return NotFoundValue; |
| 1350 | } |
| 1351 | auto index = it->second; |
| 1352 | if (++it != p.second) { |
| 1353 | // Duplicate field name |
| 1354 | return DuplicateFoundValue; |
| 1355 | } |
| 1356 | return index; |
| 1357 | } |
| 1358 | |
| 1359 | } // namespace |
| 1360 |