| 75 | } |
| 76 | |
| 77 | void FriendlyNameMapper::SaveName(uint32_t id, |
| 78 | const std::string& suggested_name) { |
| 79 | if (name_for_id_.find(id) != name_for_id_.end()) return; |
| 80 | |
| 81 | const std::string sanitized_suggested_name = Sanitize(suggested_name); |
| 82 | std::string name = sanitized_suggested_name; |
| 83 | auto inserted = used_names_.insert(name); |
| 84 | if (!inserted.second) { |
| 85 | const std::string base_name = sanitized_suggested_name + "_"; |
| 86 | for (uint32_t index = 0; !inserted.second; ++index) { |
| 87 | name = base_name + to_string(index); |
| 88 | inserted = used_names_.insert(name); |
| 89 | } |
| 90 | } |
| 91 | name_for_id_[id] = name; |
| 92 | } |
| 93 | |
| 94 | void FriendlyNameMapper::SaveBuiltInName(uint32_t target_id, |
| 95 | uint32_t built_in) { |