Yeah, I ran the comparator on the main docs and on all the docs
generated by the jtreg tests.
-- Jon
On 12/18/19 6:57 AM, Kumar Srinivasan wrote:
Hi Jon,
Looks great, one suggestion. If you have already not, please run the
old vs new comparator, it would be good to understand if there is a WS
change.
Kumar
On Dec 16, 2019, at 2:47 PM, Jonathan Gibbons
<[email protected] <mailto:[email protected]>> wrote:
Updated webrev based on Ivan's suggestion to use one of
stripLeading(), stripTrailing(), or strip() instead of the old
methods, which are now removed
-- Jon
https://nam04.safelinks.protection.outlook.com/?url=http:%2F%2Fcr.openjdk.java.net%2F~jjg%2F8236030%2Fwebrev.01%2F&data=02%7C01%7Ckusrinivasan%40vmware.com%7C9fe27dd9cda542bdfab508d78279fdf4%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C637121332788148197&sdata=wEqf9%2BjREFiOuR37yWRaXU6cU%2ByW4p0ERRE0IgshQP8%3D&reserved=0
On 12/16/2019 01:33 PM, Jonathan Gibbons wrote:
Ivan,
Great suggestion, and sets up the possibility to use strip() when
both leading and trailing whitespace should be removed.
The only slight change in semantics would be that these methods work
in terms of code-points, not characters, and javadoc has not (yet?)
been adapted to use code-points throughout.
-- Jon
On 12/16/2019 01:23 PM, Ivan Gerasimov wrote:
Hello!
Can String.stripLeading()/stripTrailing() methods be used instead,
or is there a reason to avoid them?
With kind regards,
Ivan
On 12/16/19 1:10 PM, Jonathan Gibbons wrote:
Please review a tiny change to eliminate a string copy into a
temporary character buffer when removing leading or trailing
whitespace from a string.
The affected methods are called within the main code to translate
doc comments to HTML. This is noreg-cleanup/no-reg-trivial, so no
new additional tests.
Webrev below, but the patch is also included here:
---
a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
Mon Dec 16 15:33:03 2019 -0500
+++
b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
Mon Dec 16 13:07:18 2019 -0800
@@ -1604,22 +1604,19 @@
}
private String removeTrailingWhitespace(String text) {
- char[] buf = text.toCharArray();
- for (int i = buf.length - 1; i > 0 ; i--) {
- if (!Character.isWhitespace(buf[i]))
- return text.substring(0, i + 1);
+ int i = text.length() - 1;
+ while (i >= 0 && Character.isWhitespace(text.charAt(i))) {
+ i--;
}
- return text;
+ return i == text.length() - 1 ? text : text.substring(0,
i + 1);
}
private String removeLeadingWhitespace(String text) {
- char[] buf = text.toCharArray();
- for (int i = 0; i < buf.length; i++) {
- if (!Character.isWhitespace(buf[i])) {
- return text.substring(i);
- }
+ int i = 0;
+ while (i < text.length() &&
Character.isWhitespace(text.charAt(i))) {
+ i++;
}
- return text;
+ return i == 0 ? text : text.substring(i);
}
/**
-- Jon
JBS:https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugs.openjdk.java.net%2Fbrowse%2FJDK-8236030&data=02%7C01%7Ckusrinivasan%40vmware.com%7C9fe27dd9cda542bdfab508d78279fdf4%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C637121332788148197&sdata=nzYllB4CNA7TaC6t0YAWGbF2IrV3xvGCLm4UxC1hTVY%3D&reserved=0
Webrev:https://nam04.safelinks.protection.outlook.com/?url=http:%2F%2Fcr.openjdk.java.net%2F~jjg%2F8236030%2Fwebrev%2F&data=02%7C01%7Ckusrinivasan%40vmware.com%7C9fe27dd9cda542bdfab508d78279fdf4%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C637121332788148197&sdata=rU%2BTvxwi3JID66kCEZkvbfEFpe4ZuHhjEK46oWxao98%3D&reserved=0