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

Generate code that formats faster with "short" style. #1336

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

davidmorgan
Copy link
Collaborator

@davidmorgan davidmorgan commented Dec 18, 2024

For #1335

Before:

dart format --language-version=3.6 */lib/*.g.dart
Formatted 20 files (0 changed) in 3.55 seconds.

After:

dart format --language-version=3.6 */lib/*.g.dart
Formatted 20 files (0 changed) in 1.01 seconds.

Note that the speedup is more than 3.5x as "dart format" has some startup time.

Copy link
Contributor

@iinozemtsev iinozemtsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@iinozemtsev
Copy link
Contributor

so the trick is to proactively add a trailing comma?

@davidmorgan
Copy link
Collaborator Author

so the trick is to proactively add a trailing comma?

Right, that switches to the less-indented format that's more like the new "tall" style. And also turns out to be faster in this case :)

@davidmorgan davidmorgan merged commit 306b669 into google:master Dec 18, 2024
2 checks passed
@davidmorgan davidmorgan deleted the format-performance branch December 18, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants