sdedic commented on code in PR #4975:
URL: https://github.com/apache/netbeans/pull/4975#discussion_r1024407861
##########
nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java:
##########
@@ -226,12 +226,16 @@ private void cleanUpDependDebris() {
continue;
}
int i = clazz.indexOf('$');
- File enclosing = new File(d, clazz.substring(0, i) + ".class");
- if (!enclosing.isFile()) {
- File enclosed = new File(d, clazz);
- log(clazz + " will be deleted since " + enclosing.getName() +
" is missing", Project.MSG_VERBOSE);
- if (!enclosed.delete()) {
- throw new BuildException("could not delete " + enclosed,
getLocation());
+ // ignore filenames that start right with '$' (separatorChar
preceded), these could not be inner classes.
+ if (i > 0 && clazz.charAt(i - 1) != File.separatorChar) {
+ File enclosing = new File(d, clazz.substring(0, i) + ".class");
Review Comment:
Let's have some fun. I was curious, so I wrote a dumb testcase:
```
long n1 = System.nanoTime();
for (long i = 0; i < 100000000L; i++) {
int index = S.indexOf('$');
String x = S.substring(0, index) + ".class";
A[0] = x;
}
long n2 = System.nanoTime();
for (long i = 0; i < 100000000L; i++) {
int index = S.indexOf('$');
String x = S.substring(0, index).concat(".class");
A[0] = x;
}
long n3 = System.nanoTime();
System.err.println("First: " + (n2 - n1));
System.err.println("Second: " + (n3 - n2));
```
What was funy was the result:
```
First: 3339608014
Second: 3703034326
```
(Oracle JDK11)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists