mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
Type: Add TypeManager->TypeList() and use for ListVal()
It turns out that for every ListVal we construct, we also allocate and construct a new TypeList instance, even though they are all the same. Pre-create and cache the type instances in a new TypeManager. The following script runs ~10% faster for me after this change. global tbl: table[string] of string; global i = 0; while ( ++i < 10000000 ) tbl["a"] = "a";
This commit is contained in:
parent
04a2ee7220
commit
24c606b4df
4 changed files with 36 additions and 4 deletions
|
@ -1188,10 +1188,7 @@ ValPtr PatternVal::DoClone(CloneState* state)
|
|||
return state->NewClone(this, make_intrusive<PatternVal>(re));
|
||||
}
|
||||
|
||||
ListVal::ListVal(TypeTag t) : Val(make_intrusive<TypeList>(t == TYPE_ANY ? nullptr : base_type(t)))
|
||||
{
|
||||
tag = t;
|
||||
}
|
||||
ListVal::ListVal(TypeTag t) : Val(type_mgr->TypeList(t)), tag(t) { }
|
||||
|
||||
ListVal::~ListVal() { }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue