Skip to content

[Variant] Optimize parse_in_bracket to avoid unnecessary String allocations #9493

Closed

Description

@codephage2020

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

I've noticed that parse_in_bracket in parquet-variant/src/utils.rs always allocates a String when parsing bracket expressions like [field] or [0], even when no escaping is needed:

fn parse_in_bracket(s: &str, i: usize) -> Result<(VariantPathElement<'_>, usize), ArrowError> {
    let start = i + 1;
    let mut unescaped = String::new();  // <-- Always allocates!
    // ...
}

Describe the solution you'd like

I'm thinking of optimizing this by:

  1. Check if the content contains \ before allocating
  2. Since VariantPathElement already supports Cow<'a, str>, we could borrow the slice directly when no escaping is present
  3. Only allocate when we actually encounter escape sequences

Activity

  1. added
    enhancement
    on Feb 28, 2026
  2. changed the title [-]Optimize parse_in_bracket to avoid unnecessary String allocations[/-] [+][Variant] Optimize parse_in_bracket to avoid unnecessary String allocations[/+] on Sep 26, 2026
  3. DKER2 commented on Sep 27, 2026

    @DKER2
    Contributor

    take

  4. added a commit that references this issue on Oct 27, 2026
    dc59495
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions