Skip to content

Optimize newline processing - #208

Closed
novalis wants to merge 1 commit into
google:masterfrom
novalis:faster
Closed

novalis wants to merge 1 commit into
google:masterfrom
novalis:faster

Conversation

@novalis

@novalis novalis commented Oct 10, 2017

Copy link
Copy Markdown

This makes google-java-format as a whole run in about a third of the
time on my (already-correctly-formatted) codebase.

I could probably use a cache with an LRU eviction policy here, but it's not clear what size is reasonable. I could also do a per-file cache, but (a) often most files start with the same copyright header, and (b) the most-frequently-used item in the cache is " ", so there's some between-files sharing.

This makes google-java-format as a whole run in about a third of the
time on my (already-correctly-formatted) codebase.
@cushon

cushon commented Oct 10, 2017

Copy link
Copy Markdown
Collaborator

Thanks for catching this. I think there's an underlying bug that's causing this code to be called more than it should be.

Can you you how the performance of this fix compares to cushon@b9751f3 on your codebase?

@novalis

novalis commented Oct 10, 2017 •

Copy link
Copy Markdown
Author

Yours is better (7s vs 8s on my random test codebase). I'm closing this PR, on the assumption that you'll merge yours.

@novalis novalis closed this Oct 10, 2017
cushon added a commit that referenced this pull request Oct 12, 2017
… the last token

This was causing JavaInput to spend a lot of time computing the end
column on the last line of that column, see
#208

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants