Skip to content

performance: Appends to region_highlight are quadratic? #388

@danielshahaf

Description

@danielshahaf
Member

@psprint reports that appending to $region_highlight is faster if first accumulating to another array and then appending to $region_highlight in one shot, compared to appending to $region_highlight directly.

Speculation: this may be because the $region_highlight is a special array (in the ${(t)foo} sense), and because the array's setfn is called on the entire array each time, not only on the appended portion.

  • Investigate the difference quantitatively
    If needed, switch from appending directly to using a temporary array

Activity

danielshahaf

danielshahaf commented on Nov 8, 2016

@danielshahaf
MemberAuthor

workers/39869 might be related.

danielshahaf

danielshahaf commented on Nov 26, 2017

@danielshahaf
MemberAuthor

If needed, switch from appending directly to using a temporary array

Note that array appends are quadratic too, independently of region_highlight's setter. Possibly with a smaller big-O constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @danielshahaf

        Issue actions

          performance: Appends to region_highlight are quadratic? · Issue #388 · zsh-users/zsh-syntax-highlighting