Skip to content

Commit

Permalink
feat: improve ArexStringEqualsUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
rchen9 committed Oct 30, 2024
1 parent e581161 commit d8421d3
Showing 1 changed file with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,21 @@ public static boolean isEqualsWithoutPrefix(String baseStr, String testStr) {
int baseIndex = 0;
int testIndex = 0;

if (baseValueLen == 0) {
while (testIndex < testValueLen) {
if (isPrefix(testIndex, testStr)) {
testIndex = testIndex + 5;
} else {
return false;
}
while (testIndex < testValueLen) {
if (isPrefix(testIndex, testStr)) {
testIndex = testIndex + 5;
continue;
}
return true;
} else {
while (testIndex < testValueLen) {
if (isPrefix(testIndex, testStr)) {
testIndex = testIndex + 5;
continue;
}
if (baseIndex >= baseValueLen) {
return false;
}
if (baseStr.charAt(baseIndex) != testStr.charAt(testIndex)) {
return false;
}
baseIndex++;
testIndex++;
if (baseIndex >= baseValueLen) {
return false;
}
return true;
if (baseStr.charAt(baseIndex) != testStr.charAt(testIndex)) {
return false;
}
baseIndex++;
testIndex++;
}
return true;
}

private static boolean isPrefix(int testIndex, String testValue) {
Expand Down

0 comments on commit d8421d3

Please sign in to comment.