[pigeon] Switch Indent class to manage all writes with a StringBuffer#11133
[pigeon] Switch Indent class to manage all writes with a StringBuffer#11133auto-submit[bot] merged 4 commits intoflutter:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the Indent class to manage all write operations with an internal StringBuffer instead of writing directly to an IOSink. This change aims to improve performance by buffering writes and reducing I/O operations. Consequently, the Indent class constructor no longer accepts a sink, and its toString() method is now used to retrieve the generated string. All call sites have been updated to instantiate Indent, use it for string construction, and then write the final content from indent.toString() to the target sink.
tarrinneal
left a comment
There was a problem hiding this comment.
This should also probably have a version bump.
Do you know if the formatting changes at all before the format tool runs?
|
I was wondering, when you have serveral in-flight PRs, do you just bump the version in each of them, even though you know all but one will be wrong? Just a game of merging main branch, bump version again; merge main branch, bump version again? |
|
I usually do, that way whatever is ready first can land. I know when I review, seeing all passing tests helps me know something is ready to be looked at. |
|
Version bumped. |
We change the Indent class to not accept an IOSink. Instead, it manages all writes in its own StringBuffer, and then its
toString()method can be used to extract out the written text.This dramatically reduces the number of write operations sent to the OS. Functionally, it is a no-op, but should have various performance improvements. Generating Dart files may be overall faster.
Using this PR, I find that the number of file operations is reduced from 166k operations to 3142 operations. 🎉
Fixes flutter/flutter#182958
Pre-Review Checklist
[shared_preferences]///).