Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c8d2e45

Browse files
committed
WithourString: minor improvements
1 parent a82a57f commit c8d2e45

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/java/com/rampatra/strings/WithoutString.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
public class WithoutString {
1515

16-
public static String withoutString(String base, String remove) {
16+
private static String withoutString(String base, String remove) {
1717
String original = base;
1818
base = base.toLowerCase();
1919
remove = remove.toLowerCase();
@@ -24,10 +24,8 @@ public static String withoutString(String base, String remove) {
2424
for (int i = 0; i < baseLen; ) {
2525
int j = 0;
2626
// when we see a match, advance the pointer
27-
if (base.charAt(i) == remove.charAt(0)) {
28-
while (j < removeLen && i + j < baseLen && base.charAt(i + j) == remove.charAt(j)) {
29-
j++;
30-
}
27+
while (j < removeLen && i + j < baseLen && base.charAt(i + j) == remove.charAt(j)) {
28+
j++;
3129
}
3230
if (j == removeLen) { // an entire match was found, move ahead and skip these chars
3331
i += removeLen;

0 commit comments

Comments
 (0)