Scope: delete duplicate locals

This commit is contained in:
Max Kellermann 2020-02-26 07:56:26 +01:00
parent 783f833d5f
commit cbb6f09726

View file

@ -31,7 +31,15 @@ public:
}
template<typename N>
void Insert(N &&name, ID* id) { local[std::forward<N>(name)] = id; }
void Insert(N &&name, ID* id)
{
auto i = local.emplace(std::forward<N>(name), id);
if ( ! i.second )
{
Unref(i.first->second);
i.first->second = id;
}
}
template<typename N>
ID* Remove(N &&name)