Skip to content

Commit

Permalink
#52: rewrite replaceFirst method
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeFcosta committed Jan 31, 2023
1 parent 82dbfbb commit 5f2a2ac
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1020,11 +1020,9 @@ private static void replace(StringBuilder sb, String a, String b) {

private static void replaceFirst(StringBuilder sb, String a, String b) {
int pos = 0;
while ((pos = sb.indexOf(a, pos)) >= 0) {
String rep = b == null ? "-" : b; //$NON-NLS-1$
if ((pos = sb.indexOf(a, pos)) >= 0) {
String rep = b == null ? "-" : b;
sb.replace(pos, pos + a.length(), rep);
pos += rep.length();
break;
}
}

Expand Down

0 comments on commit 5f2a2ac

Please sign in to comment.