Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.1
-
None
-
None
-
Operating System: other
Platform: Other
-
39368
Description
static String replace(String text, String repl, String with, int max)
PROBLEM:
This method incurs the calculation of the search string ("repl") every time a
match is found.
int start = 0, end = 0;
while ((end = text.indexOf(repl, start)) != -1)
PROPOSED SOLUTION:
Move it out of the loop.
int start = 0, end = 0, replLen = repl.length();
while ((end = text.indexOf(repl, start)) != -1)