Closed Arnaud-Nauwynck closed 3 years ago
@Arnaud-Nauwynck , I am not a maintainer (@hboutemy is?), but I will try to look through the commit to try to speed up the process a bit
While I agree about Writer != OutputStream, I don't think it's wise to just rename 4 classes in the library, that will break everything.
@gnodet, I am very glad you have a look to this PR. I understand that the change from Stream to Writer will break dependencies. If you really think these classes OutputStream are part of a public API, maybe it is still possible to keep theses classes unmodified, do not use them internally, and mark them as @Deprecated (for future removal ?) I believe most users will use Jansi public API only with "AnsiConsole.systemInstall()", and "ansi()" helper methods, and would not touch any internal OutputStream/Writer classes.
The initial goal was not to do refactoring, but to improve the performance bottlenecks due to lack of buffering and avoiding the system calls flush() char per char (byte per byte..)... so it really has to be considered with optimization pull request #150 (and #149 is the corresponding benchmark test)... to gain a performance factor ~ x2.5
I understand my PR has to be considered as a proof-of-concept and work in progress, with backward-compatibility to enhance, code to cleanup, comments to add, unit tests, etc...
Regards,
changed OutputStream to Writer ... so method "write(int)" now receive and interpret argument as "char" instead of "byte" also implement/override methods write(char[]), write(char[],int,int), write(String), write(CharSequence) ...
rename accordingly AnsiOutputStream -> AnsiFilterWriter HtmlAnsiOutputStream -> HtmlAnsiFilterWriter
there is no more encoding problem in strange conversion byte[]->String using new String(..Charset.defaultCharset()), or String->byte[] using String.getBytes(.. "UTF-8") There is also no more suspect int->(byte) conversion, but int->(char)