mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
streamlining of some script optimization APIs
This commit is contained in:
parent
f7b739a47d
commit
896238c173
3 changed files with 13 additions and 12 deletions
|
@ -550,22 +550,23 @@ static std::unordered_map<std::string, unsigned int> func_attrs = {
|
|||
// Some of these have side effects that could be checked for in a specific
|
||||
// context, but the gains from doing so likely aren't worth the complexity.
|
||||
|
||||
bool is_special_script_func(std::string func_name) {
|
||||
bool is_special_script_func(const std::string& func_name) {
|
||||
auto f_attr = func_attrs.find(func_name);
|
||||
return f_attr != func_attrs.end() && (f_attr->second & ATTR_SPECIAL_SCRIPT_FUNC) != 0;
|
||||
}
|
||||
|
||||
bool is_idempotent(std::string func_name) {
|
||||
bool is_idempotent(const std::string& func_name) {
|
||||
auto f_attr = func_attrs.find(func_name);
|
||||
return f_attr != func_attrs.end() && (f_attr->second & ATTR_IDEMPOTENT) != 0;
|
||||
}
|
||||
|
||||
bool has_no_script_side_effects(std::string func_name) {
|
||||
bool has_script_side_effects(const std::string& func_name) {
|
||||
auto f_attr = func_attrs.find(func_name);
|
||||
if ( f_attr == func_attrs.end() )
|
||||
return false;
|
||||
// We don't know about it, so be conservative.
|
||||
return true;
|
||||
|
||||
return (f_attr->second & (ATTR_NO_SCRIPT_SIDE_EFFECTS | ATTR_NO_ZEEK_SIDE_EFFECTS | ATTR_IDEMPOTENT)) != 0;
|
||||
return (f_attr->second & (ATTR_NO_SCRIPT_SIDE_EFFECTS | ATTR_NO_ZEEK_SIDE_EFFECTS | ATTR_IDEMPOTENT)) == 0;
|
||||
}
|
||||
|
||||
} // namespace zeek::detail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue