Using StringBuilder in StringUtils#capitalize method

StringBuffer is synchronized which is slower and should be replaced with
StringBuilder according to its Javadoc.

Change-Id: If4d4a5a49da289ded34bbec97132ab7636b937cc
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
This commit is contained in:
Lars Vogel 2019-12-17 23:51:00 +01:00 committed by Matthias Sohn
parent 2db0c6bb7a
commit ccd68dc1dc
1 changed files with 1 additions and 1 deletions

View File

@ -121,7 +121,7 @@ public static String capitalize(String str) {
if (str == null || (strLen = str.length()) == 0) { if (str == null || (strLen = str.length()) == 0) {
return str; return str;
} }
return new StringBuffer(strLen) return new StringBuilder(strLen)
.append(Character.toTitleCase(str.charAt(0))) .append(Character.toTitleCase(str.charAt(0)))
.append(str.substring(1)).toString(); .append(str.substring(1)).toString();
} }