Skip to content
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

Closed
tony19 opened this issue Jun 12, 2018 · 3 comments
Closed

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

tony19 opened this issue Jun 12, 2018 · 3 comments

Comments

@tony19
Copy link
Contributor

@tony19 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
Copy link
Contributor Author

@tony19 tony19 commented Jun 13, 2018

Possibly related to #1250 and #2259

@fisker
Copy link
Member

@fisker fisker commented May 22, 2020

This is not slow anymore, not sure how and when it got improved

@thorn0
Copy link
Collaborator

@thorn0 thorn0 commented May 22, 2020

#6229 fixed it most probably.

@thorn0 thorn0 closed this May 22, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants