Skip to content

Copying Map in insert_view_link_by_node #2801

@acl-cqc

Description

@acl-cqc

Following #2792 we are copying a HashMap into a BTreeMap to maintain determinism, as the HashMap (NodeLinkingDirectives) is a public type alias. Changing this to BTreeMap would be breaking but would allow avoiding the copy, here:

// (This may be slow for large numbers of module-children, but not total size of Hugr)
let mut nodes = BTreeSet::new();
if parent.is_some() {
nodes.extend(other.entry_descendants());
}
nodes.extend(children.iter().flat_map(|(&ch, dirv)| match dirv {
NodeLinkingDirective::Add { .. } => Either::Left(other.descendants(ch)),
NodeLinkingDirective::UseExisting(_) => Either::Right(std::iter::once(ch)),
}));

Metadata

Metadata

Assignees

No one assigned

    Labels

    perfPerformance issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions