-
Notifications
You must be signed in to change notification settings - Fork 1
Description
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.