You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/05/05 11:51:23 UTC
[07/14] [text] optimized empty check with StringUtils.isEmpty
optimized empty check with StringUtils.isEmpty
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/e3ea9dda
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/e3ea9dda
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/e3ea9dda
Branch: refs/heads/master
Commit: e3ea9dda89df37911876272f4ad0419c84f6fc50
Parents: a611df5
Author: Amey Jadiye <am...@gmail.com>
Authored: Thu May 4 20:40:13 2017 +0530
Committer: Amey Jadiye <am...@gmail.com>
Committed: Thu May 4 20:40:13 2017 +0530
----------------------------------------------------------------------
src/main/java/org/apache/commons/text/WordUtils.java | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/e3ea9dda/src/main/java/org/apache/commons/text/WordUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/WordUtils.java b/src/main/java/org/apache/commons/text/WordUtils.java
index 0d7a762..34c0728 100644
--- a/src/main/java/org/apache/commons/text/WordUtils.java
+++ b/src/main/java/org/apache/commons/text/WordUtils.java
@@ -760,12 +760,9 @@ public class WordUtils {
* @return the abbreviated String.
*/
public static String abbreviate(String str, int lower, int upper, String appendToEnd) {
- if (str == null) {
- return null;
- }
- if (str.length() == 0) {
- return StringUtils.EMPTY;
+ if (StringUtils.isEmpty(str)) {
+ return str;
}
// if the lower value is greater than the length of the string,