mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Scope: delete duplicate locals
This commit is contained in:
parent
783f833d5f
commit
cbb6f09726
1 changed files with 9 additions and 1 deletions
10
src/Scope.h
10
src/Scope.h
|
@ -31,7 +31,15 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename N>
|
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>
|
template<typename N>
|
||||||
ID* Remove(N &&name)
|
ID* Remove(N &&name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue