Skip to content

Address known TODO/inefficiency in _config_to_get_to_right() #191

@jtdub

Description

@jtdub

Description

_config_to_get_to_right() in base.py:457-459 contains a self-acknowledged inefficiency:

# This creates a new HConfigChild object just in case there are some delta children.
# This is not very efficient, think of a way to not do this.
subtree = delta.instantiate_child(target_child.text)

A temporary HConfigChild is created for every matching child during remediation computation, even when there turn out to be no delta children. The object is only appended to delta if it has children (line 462), meaning many of these allocations are wasted.

Possible Approaches

  1. Defer child creation — check if there would be children before creating the subtree node
  2. Use a lightweight sentinel/proxy object instead of a full HConfigChild for the probe
  3. Add the child optimistically and remove it if empty (current approach, but reversed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions