-
-
Notifications
You must be signed in to change notification settings - Fork 254
perf: Use a buffered writer to reduce IO overhead #347
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
Conversation
The JavaDoc of StreamResult says that you should use OutputStream usually.
So it should be Moreover, you can use |
|
it.outputStream().buffered().use { output ->
TransformerFactory.newInstance()
.newTransformer()
.transform(DOMSource(this), StreamResult(output))
} Will force a buffered path, but it does not differ from the approach it.bufferedWriter().use { writer ->
TransformerFactory.newInstance()
.newTransformer()
.transform(DOMSource(this), StreamResult(writer))
} FileOutputStream is not buffered by default, so when you write to a FileOutputStream, every write() call can result in a system-level I/O operation, which is what it was asked to fix/avoid in this PR no ? |
Apparently, it does not
|
Which method would you prefer ReVanced to use — File.outputStream().buffered() or File.bufferedWriter()? From a system-level performance perspective, they are effectively equivalent. |
I think ReVanced should use OutputStream according to the JavaDoc. |
As ToSteam (used by XMLTransformer) writes char by char, using a buffered writer improves significantly the performance of the writing.
Done |
# [21.1.0-dev.2](v21.1.0-dev.1...v21.1.0-dev.2) (2025-06-20) ### Bug Fixes * Add back missing log by naming logger correctly ([#332](#332)) ([e4e66b0](e4e66b0)) * Support UTF-8 chars when compiling instructions in Smali in non UTF-8 environments ([#331](#331)) ([bb8771b](bb8771b)) ### Features * Use option name as key for simplicity and consistency ([754b02e](754b02e)) ### Performance Improvements * Use a buffered writer to reduce IO overhead ([#347](#347)) ([99f4318](99f4318))
As ToSteam (used by XMLTransformer) writes char by char, using a buffered writer improves significantly the performance of the writing.
See #339 for the tests and the discussion