mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Implement standard-library-compatible iterators for Dictionary
This commit is contained in:
parent
9e9998c6e5
commit
892124378c
16 changed files with 834 additions and 254 deletions
|
@ -183,16 +183,14 @@ function Reporter::set_weird_sampling_whitelist%(weird_sampling_whitelist: strin
|
|||
auto wl_table = wl_val->AsTable();
|
||||
std::unordered_set<std::string> whitelist_set;
|
||||
|
||||
zeek::detail::HashKey* k;
|
||||
IterCookie* c = wl_table->InitForIteration();
|
||||
TableEntryVal* v;
|
||||
|
||||
while ( (v = wl_table->NextEntry(k, c)) )
|
||||
for ( const auto& tble : *wl_table )
|
||||
{
|
||||
auto k = tble.GetHashKey();
|
||||
auto* v = tble.GetValue<TableEntryVal*>();
|
||||
|
||||
auto index = wl_val->RecreateIndex(*k);
|
||||
string key = index->Idx(0)->AsString()->CheckString();
|
||||
whitelist_set.emplace(move(key));
|
||||
delete k;
|
||||
}
|
||||
reporter->SetWeirdSamplingWhitelist(std::move(whitelist_set));
|
||||
return zeek::val_mgr->True();
|
||||
|
@ -223,16 +221,12 @@ function Reporter::set_weird_sampling_global_list%(weird_sampling_global_list: s
|
|||
auto wl_table = wl_val->AsTable();
|
||||
std::unordered_set<std::string> global_list_set;
|
||||
|
||||
zeek::detail::HashKey* k;
|
||||
IterCookie* c = wl_table->InitForIteration();
|
||||
TableEntryVal* v;
|
||||
|
||||
while ( (v = wl_table->NextEntry(k, c)) )
|
||||
for ( const auto& tble : *wl_table )
|
||||
{
|
||||
auto k = tble.GetHashKey();
|
||||
auto index = wl_val->RecreateIndex(*k);
|
||||
string key = index->Idx(0)->AsString()->CheckString();
|
||||
global_list_set.emplace(move(key));
|
||||
delete k;
|
||||
}
|
||||
reporter->SetWeirdSamplingGlobalList(std::move(global_list_set));
|
||||
return zeek::val_mgr->True();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue