mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 16:18:19 +00:00
script optimization support for using strings to index table[pattern] values
This commit is contained in:
parent
fd1094a184
commit
61fcca8482
5 changed files with 81 additions and 5 deletions
|
@ -44,6 +44,10 @@ ValPtr index_table__CPP(const TableValPtr& t, vector<ValPtr> indices) {
|
|||
return v;
|
||||
}
|
||||
|
||||
ValPtr index_patstr_table__CPP(const TableValPtr& t, vector<ValPtr> indices) {
|
||||
return t->LookupPattern(indices[0]->AsStringVal());
|
||||
}
|
||||
|
||||
ValPtr index_vec__CPP(const VectorValPtr& vec, int index) {
|
||||
if ( index < 0 )
|
||||
index += vec->Size();
|
||||
|
@ -66,6 +70,13 @@ ValPtr when_index_table__CPP(const TableValPtr& t, vector<ValPtr> indices) {
|
|||
return v;
|
||||
}
|
||||
|
||||
ValPtr when_index_patstr__CPP(const TableValPtr& t, vector<ValPtr> indices) {
|
||||
auto v = index_patstr_table__CPP(t, std::move(indices));
|
||||
if ( v && IndexExprWhen::evaluating > 0 )
|
||||
IndexExprWhen::results.emplace_back(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
ValPtr when_index_vec__CPP(const VectorValPtr& vec, int index) {
|
||||
auto v = index_vec__CPP(vec, index);
|
||||
if ( v && IndexExprWhen::evaluating > 0 )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue