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

Side by Side Diff: src/string.js

Issue 1146523002: Store fewer arrays in the context snapshot. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove debug output Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « src/i18n.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $stringCharAt; 5 var $stringCharAt;
6 var $stringIndexOf; 6 var $stringIndexOf;
7 var $stringSubstring; 7 var $stringSubstring;
8 8
9 (function(global, shared, exports) { 9 (function(global, shared, exports) {
10 10
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 if (result !== null) $regexpLastMatchInfoOverride = null; 163 if (result !== null) $regexpLastMatchInfoOverride = null;
164 regexp.lastIndex = 0; 164 regexp.lastIndex = 0;
165 return result; 165 return result;
166 } 166 }
167 // Non-regexp argument. 167 // Non-regexp argument.
168 regexp = new GlobalRegExp(regexp); 168 regexp = new GlobalRegExp(regexp);
169 return $regexpExecNoTests(regexp, subject, 0); 169 return $regexpExecNoTests(regexp, subject, 0);
170 } 170 }
171 171
172 172
173 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
174
175
176 // ECMA-262 v6, section 21.1.3.12 173 // ECMA-262 v6, section 21.1.3.12
177 // 174 //
178 // For now we do nothing, as proper normalization requires big tables. 175 // For now we do nothing, as proper normalization requires big tables.
179 // If Intl is enabled, then i18n.js will override it and provide the the 176 // If Intl is enabled, then i18n.js will override it and provide the the
180 // proper functionality. 177 // proper functionality.
181 function StringNormalizeJS(form) { 178 function StringNormalizeJS(form) {
182 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); 179 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
183 180
184 var form = form ? TO_STRING_INLINE(form) : 'NFC'; 181 var form = form ? TO_STRING_INLINE(form) : 'NFC';
182
183 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
184
185 var normalizationForm = NORMALIZATION_FORMS.indexOf(form); 185 var normalizationForm = NORMALIZATION_FORMS.indexOf(form);
186 if (normalizationForm === -1) { 186 if (normalizationForm === -1) {
187 throw MakeRangeError(kNormalizationForm, NORMALIZATION_FORMS.join(', ')); 187 throw MakeRangeError(kNormalizationForm, NORMALIZATION_FORMS.join(', '));
188 } 188 }
189 189
190 return %_ValueOf(this); 190 return %_ValueOf(this);
191 } 191 }
192 192
193 193
194 // This has the same size as the $regexpLastMatchInfo array, and can be used 194 // This has the same size as the $regexpLastMatchInfo array, and can be used
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 // If start isn't valid, return undefined. 403 // If start isn't valid, return undefined.
404 if (start < 0) return; 404 if (start < 0) return;
405 var end = lastCaptureInfo[CAPTURE(scaled + 1)]; 405 var end = lastCaptureInfo[CAPTURE(scaled + 1)];
406 return %_SubString(string, start, end); 406 return %_SubString(string, start, end);
407 } 407 }
408 408
409 409
410 // TODO(lrn): This array will survive indefinitely if replace is never 410 // TODO(lrn): This array will survive indefinitely if replace is never
411 // called again. However, it will be empty, since the contents are cleared 411 // called again. However, it will be empty, since the contents are cleared
412 // in the finally block. 412 // in the finally block.
413 var reusableReplaceArray = new InternalArray(16); 413 var reusableReplaceArray = new InternalArray(4);
414 414
415 // Helper function for replacing regular expressions with the result of a 415 // Helper function for replacing regular expressions with the result of a
416 // function application in String.prototype.replace. 416 // function application in String.prototype.replace.
417 function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) { 417 function StringReplaceGlobalRegExpWithFunction(subject, regexp, replace) {
418 var resultArray = reusableReplaceArray; 418 var resultArray = reusableReplaceArray;
419 if (resultArray) { 419 if (resultArray) {
420 reusableReplaceArray = null; 420 reusableReplaceArray = null;
421 } else { 421 } else {
422 // Inside a nested replace (replace called from the replacement function 422 // Inside a nested replace (replace called from the replacement function
423 // of another replace) or we have failed to set the reusable array 423 // of another replace) or we have failed to set the reusable array
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 "strike", StringStrike, 1170 "strike", StringStrike,
1171 "sub", StringSub, 1171 "sub", StringSub,
1172 "sup", StringSup 1172 "sup", StringSup
1173 ]); 1173 ]);
1174 1174
1175 $stringCharAt = StringCharAtJS; 1175 $stringCharAt = StringCharAtJS;
1176 $stringIndexOf = StringIndexOfJS; 1176 $stringIndexOf = StringIndexOfJS;
1177 $stringSubstring = StringSubstring; 1177 $stringSubstring = StringSubstring;
1178 1178
1179 }) 1179 })
OLDNEW
« no previous file with comments | « src/i18n.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698