Skip to content

Change javap function to write to writer #7

@ExcaliburZero

Description

@ExcaliburZero

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions