> This Pull Requests proposes an implementation for > [JDK-8341566](https://bugs.openjdk.org/browse/JDK-8341566): Adding the new > method `public static Reader Reader.of(CharSequence)` will return an > anonymous, non-synchronized implementation of a `Reader` for each kind of > `CharSequence` implementation. It is optimized for `String`, `StringBuilder`, > `StringBuffer` and `CharBuffer`. > > In addition, this Pull Request proposes to replace the implementation of > `StringReader` to become a simple synchronized wrapper around > `Reader.of(CharSequence)` for the case of `String` sources. To ensure > correctness, this PR... > * ...simply moved the **original code** of `StringBuilder` to become the > de-facto implementation of `Reader.of()`, then stripped synchronized from it > on the left hand, but kept just a synchronized wrapper on the right hand. > Then added a `switch` for optimizations within the original code, at the > exact location where previously just an optimization for `String` lived in. > * ...added tests for all methods (`Of.java`), and applied that test upon the > modified `StringBuilder`. > > Wherever new JavaDocs were added, existing phrases from other code locations > have been copied and adapted, to best match the same wording.
Markus KARG has updated the pull request incrementally with six additional commits since the last revision: - renamed source to cs; cs is final; close sets boolean; no adouble reference to source - Fixed Typo: 'resect' -> 'respect' - Improved wording: 'The returned reader supports the {@link #mark mark()} operation' - Improved wording: 'Returns a {@code Reader} that reads characters from a {@code CharSequence}, starting at the first character in the sequence' - test for generic read(char, int, int) case - Remove useless test ------------- Changes: - all: https://git.openjdk.org/jdk/pull/21371/files - new: https://git.openjdk.org/jdk/pull/21371/files/ae9f5845..5cbc0450 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=21371&range=03 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=21371&range=02-03 Stats: 42 lines in 2 files changed: 24 ins; 5 del; 13 mod Patch: https://git.openjdk.org/jdk/pull/21371.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/21371/head:pull/21371 PR: https://git.openjdk.org/jdk/pull/21371