Skip to content

FieldPath::push clones the entire vector on every call #32

@eikopf

Description

@eikopf

Location

crates/gnomon-db/src/eval/interned.rs:50-53

Description

FieldPath::push clones the entire Vec<PathSegment> to produce a new FieldPath:

pub fn push(&self, segment: PathSegment<'db>) -> Self {
    let mut segments = self.0.clone();
    segments.push(segment);
    Self(segments)
}

For deeply nested record structures, this results in O(n^2) total allocation where n is the nesting depth, since each level clones all previous segments.

Suggested Fix

Consider using Rc<[PathSegment]> for structural sharing, pre-allocating capacity, or switching to a mutable-push API where the path is built incrementally and rolled back.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions