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 2025/12/26 20:01:21 UTC
(commons-lang) 02/05: Reduce vertical space
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
commit 3d1512188634b26f108104e68e5fb1d828599ae6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Dec 26 07:36:09 2025 -0500
Reduce vertical space
---
.../java/org/apache/commons/lang3/CharSequenceUtils.java | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java b/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
index 76e79f0bd..7feb62d14 100644
--- a/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
+++ b/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java
@@ -292,8 +292,8 @@ static int lastIndexOf(final CharSequence cs, final int searchChar, int start) {
* @return whether the region matched.
* @see String#regionMatches(boolean, int, String, int, int)
*/
- static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, final int thisStart,
- final CharSequence substring, final int start, final int length) {
+ static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, final int thisStart, final CharSequence substring, final int start,
+ final int length) {
// Green implementation of regionMatches.
if (cs instanceof String && substring instanceof String) {
return ((String) cs).regionMatches(ignoreCase, thisStart, (String) substring, start, length);
@@ -301,33 +301,26 @@ static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, fi
int index1 = thisStart;
int index2 = start;
int tmpLen = length;
-
// Extract these first so we detect NPEs the same as the java.lang.String version
final int srcLen = cs.length() - thisStart;
final int otherLen = substring.length() - start;
-
// Check for invalid parameters
if (thisStart < 0 || start < 0 || length < 0) {
return false;
}
-
// Check that the regions are long enough
if (srcLen < length || otherLen < length) {
return false;
}
-
while (tmpLen-- > 0) {
final char c1 = cs.charAt(index1++);
final char c2 = substring.charAt(index2++);
-
if (c1 == c2) {
continue;
}
-
if (!ignoreCase) {
return false;
}
-
// The real same check as in String#regionMatches(boolean, int, String, int, int):
final char u1 = Character.toUpperCase(c1);
final char u2 = Character.toUpperCase(c2);
@@ -335,7 +328,6 @@ static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, fi
return false;
}
}
-
return true;
}