> On 29 Jul 2016, at 09:23, Fabian Lange <lange.fab...@gmail.com> wrote: > > This is especially sad because after having mad the String, write() > will then copy out the chars of the string and then iterate over the > chars individually.
As far as I can see no one iterates over chars individually. Instead, bulk write is invoked with the char array from the String [1]. In contrast with java.io.OutputStream, java.io.Writer encourages bulk writes, not single char writes. So the premise is that a concrete subclass provides efficient bulk write. If this doesn't hold, then one could override Writer append(CharSequence csq) in this class to behave exactly like you said. > Something an iteration over chars of the CharSequence could have > achieved much better. I'm not sure about this. But you could prove it with a set of benchmarks for concrete subclasses in the JDK. -------------------------------------------------------------------------------- [1] http://hg.openjdk.java.net/jdk9/dev/jdk/file/9410dfad9f32/src/java.base/share/classes/java/io/Writer.java#l203