mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
TableVal: Propagate &ordered through copy()
Copying an &ordered table or set would result in a copy that is not ordered. This seems rather surprising behavior, so propagate the &ordered attribute. Closes #2793
This commit is contained in:
parent
3de785114b
commit
754831d7b0
4 changed files with 71 additions and 1 deletions
14
src/Val.cc
14
src/Val.cc
|
@ -2619,7 +2619,19 @@ double TableVal::CallExpireFunc(ListValPtr idx)
|
|||
|
||||
ValPtr TableVal::DoClone(CloneState* state)
|
||||
{
|
||||
auto tv = make_intrusive<TableVal>(table_type);
|
||||
// Propagate the &ordered attribute when cloning.
|
||||
//
|
||||
// Some of the attributes are dealt with later, but this one needs to be
|
||||
// passed explicitly to the TableVal constructor so the underlying PDict
|
||||
// is initialized ordered.
|
||||
detail::AttributesPtr init_attrs = nullptr;
|
||||
if ( auto ordered_attr = GetAttr(detail::ATTR_ORDERED) )
|
||||
{
|
||||
init_attrs = zeek::make_intrusive<detail::Attributes>(table_type, false, false);
|
||||
init_attrs->AddAttr(ordered_attr);
|
||||
}
|
||||
|
||||
auto tv = make_intrusive<TableVal>(table_type, init_attrs);
|
||||
state->NewClone(this, tv);
|
||||
|
||||
const PDict<TableEntryVal>* tbl = AsTable();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue