| Index: src/string.js
|
| diff --git a/src/string.js b/src/string.js
|
| index d97f632b88dc32975830ecc2f50186199c1768ce..a75ccf0fa54f0747223e7be60845cfbd6af95d95 100644
|
| --- a/src/string.js
|
| +++ b/src/string.js
|
| @@ -144,16 +144,6 @@ function StringLastIndexOf(searchString /* position */) { // length == 1
|
| }
|
|
|
|
|
| -function CloneDenseArray(array) {
|
| - if (array === null) return null;
|
| - var clone = new $Array(array.length);
|
| - for (var i = 0; i < array.length; i++) {
|
| - clone[i] = array[i];
|
| - }
|
| - return clone;
|
| -}
|
| -
|
| -
|
| // ECMA-262 section 15.5.4.9
|
| //
|
| // This function is implementation specific. For now, we do not
|
| @@ -173,32 +163,14 @@ function StringMatch(regexp) {
|
| if (IS_REGEXP(regexp)) {
|
| if (!regexp.global) return regexp.exec(subject);
|
|
|
| - var cache = regExpCache;
|
| var saveAnswer = false;
|
|
|
| - if (%_ObjectEquals(cache.type, 'match') &&
|
| - %_IsRegExpEquivalent(cache.regExp, regexp) &&
|
| - %_ObjectEquals(cache.subject, subject)) {
|
| - if (cache.answerSaved) {
|
| - return CloneDenseArray(cache.answer);
|
| - } else {
|
| - saveAnswer = true;
|
| - }
|
| - }
|
| %_Log('regexp', 'regexp-match,%0S,%1r', [subject, regexp]);
|
| // lastMatchInfo is defined in regexp.js.
|
| - var result = %StringMatch(subject, regexp, lastMatchInfo);
|
| - cache.type = 'match';
|
| - cache.regExp = regexp;
|
| - cache.subject = subject;
|
| - if (saveAnswer) cache.answer = CloneDenseArray(result);
|
| - cache.answerSaved = saveAnswer;
|
| - return result;
|
| + return %StringMatch(subject, regexp, lastMatchInfo);
|
| }
|
| // Non-regexp argument.
|
| regexp = new $RegExp(regexp);
|
| - // Don't check regexp exec cache, since the regexp is new.
|
| - // TODO(lrn): Change this if we start caching regexps here.
|
| return RegExpExecNoTests(regexp, subject, 0);
|
| }
|
|
|
| @@ -231,7 +203,6 @@ function StringReplace(search, replace) {
|
| if (IS_REGEXP(search)) {
|
| %_Log('regexp', 'regexp-replace,%0r,%1S', [search, subject]);
|
| if (IS_FUNCTION(replace)) {
|
| - regExpCache.type = 'none';
|
| if (search.global) {
|
| return StringReplaceGlobalRegExpWithFunction(subject, search, replace);
|
| } else {
|
| @@ -273,24 +244,10 @@ function StringReplace(search, replace) {
|
|
|
| // Helper function for regular expressions in String.prototype.replace.
|
| function StringReplaceRegExp(subject, regexp, replace) {
|
| - var cache = regExpCache;
|
| - if (%_ObjectEquals(cache.type, 'replace') &&
|
| - %_IsRegExpEquivalent(cache.regExp, regexp) &&
|
| - %_ObjectEquals(cache.replaceString, replace) &&
|
| - %_ObjectEquals(cache.subject, subject)) {
|
| - return cache.answer;
|
| - }
|
| - replace = TO_STRING_INLINE(replace);
|
| - var answer = %StringReplaceRegExpWithString(subject,
|
| - regexp,
|
| - replace,
|
| - lastMatchInfo);
|
| - cache.subject = subject;
|
| - cache.regExp = regexp;
|
| - cache.replaceString = replace;
|
| - cache.answer = answer;
|
| - cache.type = 'replace';
|
| - return answer;
|
| + return %StringReplaceRegExpWithString(subject,
|
| + regexp,
|
| + TO_STRING_INLINE(replace),
|
| + lastMatchInfo);
|
| }
|
|
|
|
|
| @@ -605,34 +562,14 @@ function StringSplit(separator, limit) {
|
| return result;
|
| }
|
|
|
| - var cache = regExpCache;
|
| var saveAnswer = false;
|
|
|
| - if (%_ObjectEquals(cache.type, 'split') &&
|
| - %_IsRegExpEquivalent(cache.regExp, separator) &&
|
| - %_ObjectEquals(cache.subject, subject) &&
|
| - %_ObjectEquals(cache.splitLimit, limit)) {
|
| - if (cache.answerSaved) {
|
| - return CloneDenseArray(cache.answer);
|
| - } else {
|
| - saveAnswer = true;
|
| - }
|
| - }
|
| -
|
| - cache.type = 'split';
|
| - cache.regExp = separator;
|
| - cache.subject = subject;
|
| - cache.splitLimit = limit;
|
| -
|
| %_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]);
|
|
|
| if (length === 0) {
|
| - cache.answerSaved = true;
|
| if (splitMatch(separator, subject, 0, 0) != null) {
|
| - cache.answer = [];
|
| return [];
|
| }
|
| - cache.answer = [subject];
|
| return [subject];
|
| }
|
|
|
| @@ -680,8 +617,6 @@ function StringSplit(separator, limit) {
|
|
|
| startIndex = currentIndex = endIndex;
|
| }
|
| - if (saveAnswer) cache.answer = CloneDenseArray(result);
|
| - cache.answerSaved = saveAnswer;
|
| return result;
|
| }
|
|
|
|
|