Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d43d35f

Browse files
committed
speedup .substr( search using previous position
1 parent 0e54e6c commit d43d35f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tasks/replace_substr.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ for(var k = 0; k < allFolders.length; k++) {
2626
}
2727

2828
function replaceSubstr(str) {
29-
var i0;
29+
var i0 = 0;
3030
while(i0 !== -1) {
31-
i0 = str.indexOf('.substr(');
31+
i0 = str.indexOf('.substr(', i0);
3232
if(i0 === -1) return str;
3333

3434
var args = [];

0 commit comments

Comments
 (0)