-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b14
-
generic
-
generic
David Hovemeyer's and Bill Pugh's "findbugs" program have found some bugs in
Pattern.java. David writes:
M Dm: java.util.regex.Pattern.normalizeCharClass(StringBuffer,int) invokes dubious new String(String) constructor; just use
the argument At Pattern.java:[line 1211]
if (eq != null) {
result = new String("(?:"+charClass.toString()+
eq.toString()+")");
} else {
result = charClass.toString();
}
Just slow and embarrassing. Should be:
if (eq != null) {
result = "(?:"+charClass.toString()+
eq.toString()+")";
} else {
result = charClass.toString();
}
----
M Dm: java.util.regex.Pattern.produceEquivalentAlternation(String) invokes dubious new String(String) constructor; just use
the argument At Pattern.java:[line 1230]
private String produceEquivalentAlternation(String source) {
int len = countChars(source, 0, 1);
if (source.length() == len)
// source has one character.
return new String(source); // should be return source;
ditto.
Pattern.java. David writes:
M Dm: java.util.regex.Pattern.normalizeCharClass(StringBuffer,int) invokes dubious new String(String) constructor; just use
the argument At Pattern.java:[line 1211]
if (eq != null) {
result = new String("(?:"+charClass.toString()+
eq.toString()+")");
} else {
result = charClass.toString();
}
Just slow and embarrassing. Should be:
if (eq != null) {
result = "(?:"+charClass.toString()+
eq.toString()+")";
} else {
result = charClass.toString();
}
----
M Dm: java.util.regex.Pattern.produceEquivalentAlternation(String) invokes dubious new String(String) constructor; just use
the argument At Pattern.java:[line 1230]
private String produceEquivalentAlternation(String source) {
int len = countChars(source, 0, 1);
if (source.length() == len)
// source has one character.
return new String(source); // should be return source;
ditto.