Skip to content

Weird performance issue with assignment/arrow function/object spread combination #160

Open
@sandhose

Description

@sandhose

Hi,

I noticed a weird performance issue with some code.

foo = foo(bar => ({
  baz: {
    ...foobar.baz
  }
}));

It makes the editor completely unusable because it hangs on highlighting.

It's really a combination of multiple things, because those works:

// without assignment
foo(bar => ({
  baz: {
    ...foobar.baz
  }
}));

// spreading a variable, not a member of one
foo = foo(bar => ({
  baz: {
    ...foobar
  }
}));

// spreading in the top-level object
foo = foo(bar => ({
 ...foobar
}));

:syntime shows that typescriptArrowFuncDef seems to be the culprit:

  TOTAL      COUNT  MATCH   SLOWEST     AVERAGE   NAME               PATTERN                                                                                                                                                                  
 14.811829   271    0       5.702038    0.054656  typescriptArrowFuncDef (\(\_s*[a-zA-Z\$_\[]\_[^)]*\)*)\s*=>                                                                                                                                 
  0.000516   474    203     0.000013    0.000001  typescriptArrowFuncDef \K\k*\s*=>                                                                                                                                                           
  0.000420   271    0       0.000021    0.000002  graphqlTaggedTemplate \%(gql\|graphql\|Relay.QL\)\ze`                                                                                                                                       
  0.000320   271    0       0.000006    0.000001  typescriptNumber   \d[0-9_]*\.\d[0-9_]*\|\d[0-9_]*\|\.\d[0-9]*                                                                                                                              
  0.000271   271    0       0.000033    0.000001  typescriptArrowFuncDef (\_[^)]*):                                                                                                                                                           
  0.000230   271    0       0.000015    0.000001  typescriptArrowFuncDef ({\_[^}]*}\(:\_[^)]\)\?)\s*=>                                                                                                                                        
  0.000218   176    0       0.000020    0.000001  typescriptStringProperty \z(["']\)                                                                                                                                                          

I'm using NeoVim, tested on NixOS (linux) and MacOS

> nvim -v
NVIM v0.4.3
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: 
Compiled by nixbld

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions