-
Notifications
You must be signed in to change notification settings - Fork 1
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
Change javap function to write to writer #7
Labels
enhancement
New feature or request
Comments
Merged
Relevant code section: jvm-class-file-parser/src/main.rs Line 27 in 5435b91
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As of #5, in the main
javap
function we write the program output to a string and then at the end return that string to be printed all at once. This has the advantage of being very testable, but repeated string concatenation can potentially lead to performance issues due to repeated reallocation of increasingly larger strings.So we should change the
javap
function to take in a writer as an argument and have it write all the program output to the writer. This would allow us to pass in stdout for the executable, and for the tests use a dummy writer that could convert the output to a string to test using an assertion.We could also instead create a
OutputStreams
struct that serves this purpose, while allowing for working with both stdout and stderr. Currently we only write out to stdout, but it would be nice to also have the capability to write to stderr if we want to provide any user-targeted error messages.The text was updated successfully, but these errors were encountered: