Fixes arising from Clover report

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137530 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2003-07-30 22:17:49 +00:00
parent 45232572e2
commit 35b8cc4ce3
1 changed files with 12 additions and 12 deletions

View File

@ -146,7 +146,7 @@ import java.util.List;
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a> * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @author Phil Steitz * @author Phil Steitz
* @since 1.0 * @since 1.0
* @version $Id: StringUtils.java,v 1.81 2003/07/26 15:35:35 scolebourne Exp $ * @version $Id: StringUtils.java,v 1.82 2003/07/30 22:17:49 scolebourne Exp $
*/ */
public class StringUtils { public class StringUtils {
// Performance testing notes (JDK 1.4, Jul03, scolebourne) // Performance testing notes (JDK 1.4, Jul03, scolebourne)
@ -2331,10 +2331,10 @@ public class StringUtils {
} }
if (str.length() == 1) { if (str.length() == 1) {
if ("\r".equals(str) || "\n".equals(str)) { char ch = str.charAt(0);
if (ch == '\r' || ch == '\n') {
return ""; return "";
} } else {
else {
return str; return str;
} }
} }
@ -2615,8 +2615,8 @@ public class StringUtils {
if (repeat <= 0) { if (repeat <= 0) {
return ""; return "";
} }
int inputLength; int inputLength = str.length();
if (repeat == 1 || (inputLength = str.length()) == 0) { if (repeat == 1 || inputLength == 0) {
return str; return str;
} }
if (inputLength == 1 && repeat <= PAD_LIMIT) { if (inputLength == 1 && repeat <= PAD_LIMIT) {
@ -2771,13 +2771,13 @@ public class StringUtils {
} }
int strLen = str.length(); int strLen = str.length();
int pads = size - strLen; int pads = size - strLen;
if (pads <= 0) {
return str; // returns original String when possible
}
if (padLen == 1 && pads <= PAD_LIMIT) { if (padLen == 1 && pads <= PAD_LIMIT) {
return rightPad(str, size, padStr.charAt(0)); return rightPad(str, size, padStr.charAt(0));
} }
if (pads <= 0) {
return str; // returns original String when possible
}
if (pads == padLen) { if (pads == padLen) {
return str.concat(padStr); return str.concat(padStr);
} else if (pads < padLen) { } else if (pads < padLen) {
@ -2884,13 +2884,13 @@ public class StringUtils {
} }
int strLen = str.length(); int strLen = str.length();
int pads = size - strLen; int pads = size - strLen;
if (pads <= 0) {
return str; // returns original String when possible
}
if (padLen == 1 && pads <= PAD_LIMIT) { if (padLen == 1 && pads <= PAD_LIMIT) {
return leftPad(str, size, padStr.charAt(0)); return leftPad(str, size, padStr.charAt(0));
} }
if (pads <= 0) {
return str; // returns original String when possible
}
if (pads == padLen) { if (pads == padLen) {
return padStr.concat(str); return padStr.concat(str);
} else if (pads < padLen) { } else if (pads < padLen) {