New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`prettier.format()` slow for deeply nested function calls in input string #4672

Open
tony19 opened this Issue Jun 12, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@tony19
Copy link
Contributor

tony19 commented Jun 12, 2018

When the input string contains many (about 25) nested function calls in JavaScript, prettier.format() takes about 2.5 minutes to return. This seems to occur when coreFormat() converts the AST to a document (in printAstToDoc()).

Environment:

  • macOS High Sierra 10.13.4
  • Node 8.9.4 and 9.11.1
  • MacBook Pro 2017, 2.7GHz i7, 16GB 2133MHz LPDDR3

Prettier 1.13.5
Playground link

Input:

_c("div", [
  _c("div", [
    _c("div", [
      _c("div", [
        _c("div", [
          _c("div", [
            _c("div", [
              _c("div", [
                _c("div", [
                  _c("div", [
                    _c("div", [
                      _c("div", [
                        _c("div", [
                          _c("div", [
                            _c("div", [
                              _c("div", [
                                _c("div", [
                                  _c("div", [
                                    _c("div", [
                                      _c("div", [
                                        _c("div", [
                                          _c("div", [
                                            _c("div", [_c("div", [_c("div")])])
                                          ])
                                        ])
                                      ])
                                    ])
                                  ])
                                ])
                              ])
                            ])
                          ])
                        ])
                      ])
                    ])
                  ])
                ])
              ])
            ])
          ])
        ])
      ])
    ])
  ])
])

Output:
(same as input after 159 seconds)

Expected behavior:
prettier.format(input) returns within a few seconds (much sooner than 159 seconds)

@tony19

This comment has been minimized.

Copy link
Contributor

tony19 commented Jun 13, 2018

Possibly related to #1250 and #2259

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