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