| 148 | } |
| 149 | |
| 150 | not_null<History*> Histories::findOrCreate(PeerId peerId) { |
| 151 | Expects(peerId != 0); |
| 152 | |
| 153 | if (const auto result = find(peerId)) { |
| 154 | return result; |
| 155 | } |
| 156 | const auto &[i, ok] = _map.emplace( |
| 157 | peerId, |
| 158 | std::make_unique<History>(&owner(), peerId)); |
| 159 | return i->second.get(); |
| 160 | } |
| 161 | |
| 162 | void Histories::unloadAll() { |
| 163 | for (const auto &[peerId, history] : _map) { |