Returns the remapped id of |id| from |result_id_mapping|. If the remapped id does not exist, adds a new one to |result_id_mapping| and returns it.
| 26 | // Returns the remapped id of |id| from |result_id_mapping|. If the remapped |
| 27 | // id does not exist, adds a new one to |result_id_mapping| and returns it. |
| 28 | uint32_t GetRemappedId( |
| 29 | std::unordered_map<uint32_t, uint32_t>* result_id_mapping, uint32_t id) { |
| 30 | auto it = result_id_mapping->find(id); |
| 31 | if (it == result_id_mapping->end()) { |
| 32 | const uint32_t new_id = |
| 33 | static_cast<uint32_t>(result_id_mapping->size()) + 1; |
| 34 | const auto insertion_result = result_id_mapping->emplace(id, new_id); |
| 35 | it = insertion_result.first; |
| 36 | assert(insertion_result.second); |
| 37 | } |
| 38 | return it->second; |
| 39 | } |
| 40 | |
| 41 | } // namespace |
| 42 |