You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/06/14 12:44:23 UTC
[commons-lang] branch master updated: Fix code duplication
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new c18803a47 Fix code duplication
c18803a47 is described below
commit c18803a47f4a4e51f08c1cb1ef9b84b21e106e6f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jun 14 08:44:11 2022 -0400
Fix code duplication
---
src/main/java/org/apache/commons/lang3/text/WordUtils.java | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/text/WordUtils.java b/src/main/java/org/apache/commons/lang3/text/WordUtils.java
index 363276603..0c5cfc07b 100644
--- a/src/main/java/org/apache/commons/lang3/text/WordUtils.java
+++ b/src/main/java/org/apache/commons/lang3/text/WordUtils.java
@@ -654,7 +654,6 @@ public class WordUtils {
boolean lastWasGap = true;
for (int i = 0; i < strLen; i++) {
final char ch = str.charAt(i);
-
if (isDelimiter(ch, delimiters)) {
lastWasGap = true;
} else if (lastWasGap) {
@@ -707,22 +706,14 @@ public class WordUtils {
}
/**
- * Is the character a delimiter.
+ * Tests if the character is a delimiter.
*
* @param ch the character to check
* @param delimiters the delimiters
* @return true if it is a delimiter
*/
private static boolean isDelimiter(final char ch, final char[] delimiters) {
- if (delimiters == null) {
- return Character.isWhitespace(ch);
- }
- for (final char delimiter : delimiters) {
- if (ch == delimiter) {
- return true;
- }
- }
- return false;
+ return delimiters == null ? Character.isWhitespace(ch) : ArrayUtils.contains(delimiters, ch);
}
}