Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Only write files when content changes #249

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

Merged
merged 1 commit into from
Jan 9, 2023

Conversation

davidtaylorhq
Copy link
Contributor

Previously the CLI would call File.write for every file, even if the contents was unchanged. This unnecessary filesystem churn can have a knock-on effect on other tools which may be watching directories for changes (e.g. IDEs). This commit updates the stree write command so that it only performs a write when the file contents has changed.

There is also a very slight performance improvement in the 'happy path' when files are already formatted. Measuring runtime on Discourse's core codebase (4.3k ruby files), when all files are already formatted:

run 1 run 2 run 3 mean
Before 26.4 27.1 26.1 26.5s
After 24.3 23.8 24.4 24.2s

Presumably this difference would be larger in environments with slower filesystems.

Previously the CLI would call `File.write` for every file, even if the contents was unchanged. This unnecessary filesystem churn can have a knock-on effect on other tools which may be watching directories for changes (e.g. IDEs). This commit updates the `stree write` command so that it only performs a write when the file contents has changed.
@kddnewton
Copy link
Member

Ahh thank you this is a great change!

@kddnewton kddnewton enabled auto-merge January 9, 2023 17:01
@kddnewton kddnewton merged commit 081e6c1 into ruby-syntax-tree:main Jan 9, 2023
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