As a bonus, it avoids allocating char[] buffer for an empty string.
Add $FALL-THROUGH$ comment where we fall through to the next label in switch().
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@
1142656 13f79535-47bb-0310-9956-
ffa450edef68
/** Normalizes the given string. */
protected String normalize(String s) {
+ if (s == null) {
+ return "";
+ }
+
StringBuilder str = new StringBuilder();
- int len = (s != null) ? s.length() : 0;
+ int len = s.length();
for ( int i = 0; i < len; i++ ) {
char ch = s.charAt(i);
switch ( ch ) {
}
// else, default append char
}
+ //$FALL-THROUGH$
default: {
str.append(ch);
}