Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: src/regexp.js

Issue 3158020: Use Copy-on-write arrays for cached regexp results. (Closed)
Patch Set: Changed comments. Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/regexp.js
diff --git a/src/regexp.js b/src/regexp.js
index fa702b2a8276b078a44f52082b874596763050ce..566a96c3489ed6c525ac836338ae99c3dae73c74 100644
--- a/src/regexp.js
+++ b/src/regexp.js
@@ -137,17 +137,6 @@ function RegExpCache() {
var regExpCache = new RegExpCache();
-function CloneRegExpResult(array) {
- if (array == null) return null;
- var length = array.length;
- var answer = %_RegExpConstructResult(length, array.index, array.input);
- for (var i = 0; i < length; i++) {
- answer[i] = array[i];
- }
- return answer;
-}
-
-
function BuildResultFromMatchInfo(lastMatchInfo, s) {
var numResults = NUMBER_OF_CAPTURES(lastMatchInfo) >> 1;
var result = %_RegExpConstructResult(numResults, lastMatchInfo[CAPTURE0], s);
@@ -197,7 +186,7 @@ function RegExpExec(string) {
%_IsRegExpEquivalent(cache.regExp, this) &&
%_ObjectEquals(cache.subject, string)) {
if (cache.answerSaved) {
- return CloneRegExpResult(cache.answer);
+ return %_RegExpCloneResult(cache.answer);
} else {
saveAnswer = true;
}
@@ -251,7 +240,7 @@ function RegExpExec(string) {
cache.regExp = this;
cache.subject = s;
cache.lastIndex = lastIndex;
- if (saveAnswer) cache.answer = CloneRegExpResult(result);
+ if (saveAnswer) cache.answer = %_RegExpCloneResult(result);
cache.answerSaved = saveAnswer;
cache.type = 'exec';
}

Powered by Google App Engine
This is Rietveld 408576698