RFR: 8303078: Reduce allocations when pretty printing JCTree during compilation [v3]
Christoph Dreis
duke at openjdk.org
Wed Feb 22 21:42:16 UTC 2023
On Wed, 22 Feb 2023 21:37:02 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:
>> Christoph Dreis has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - 8303078: Replace some more character print calls
>> - 8303078: Replace some more character print calls
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocPretty.java line 82:
>
>> 80: */
>> 81: private void print(char c) throws IOException {
>> 82: out.write(c);
>
> The restriction to skip calling `Convert.escapeUnicode(s.toString())` leaks into `print(List, char sep)`.
>
> If we wanted to be paranoid we could do one or more of the following;
>
> 1. Change the body of this method to something like<br> `if (Character.isASCII(c)) out.write(c); else print((Character) c);`
> 2. include an `assert` or call to a method in `Assert.*` to verify the argument is ASCII.
> 3. change that `protected void print(List, char)` method to be `private` instead of `protected`
>
> I guess I'd not bother with 1 or 2, but maybe go with 3, since it has no effect on performance, and better restricts the functionality to just this class. I note there are no discernable external usages of this method.
Already asked above: should we really be paranoid here? There is a big class comment above that anyone depending on the internal api uses this at his own risk...
But if I should change anything I'd rather make the method `private`
-------------
PR: https://git.openjdk.org/jdk/pull/12667
More information about the compiler-dev
mailing list