Reviewers: Kasper Lund, Mads Ager, Description: Don't try an indexOf() when the search string is bigger than the string. The current code will spend a bunch of time trying to match, even though we should know a match is impossible.
Please review this at http://codereview.chromium.org/2987 Affected files: M src/string.js Index: src/string.js diff --git a/src/string.js b/src/string.js index da9ba6acb89893d0e7f070359f10912db5db5f47..1a13d16428a2dbb961578b978566ff44edf49738 100644 --- a/src/string.js +++ b/src/string.js @@ -340,6 +340,7 @@ function ApplyReplacementFunction(replace, captures, subject) { } if (index < 0) index = 0; if (index > str.length) index = str.length; + if (searchStr.length + index > str.length) return -1; return %StringIndexOf(str, searchStr, index); }, DONT_ENUM); --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
