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

Unified Diff: src/regexp.js

Issue 719403005: One instead of two runtime calls when initializing regexp. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 6 years, 1 month 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
« no previous file with comments | « src/jsregexp.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp.js
diff --git a/src/regexp.js b/src/regexp.js
index 0f3dbb630e867bb8f4d635f0ddeda9cb3a229471..e1eac76c124dbda3bc0635466617d1887fd17775 100644
--- a/src/regexp.js
+++ b/src/regexp.js
@@ -30,46 +30,7 @@ function DoConstructRegExp(object, pattern, flags) {
pattern = IS_UNDEFINED(pattern) ? '' : ToString(pattern);
flags = IS_UNDEFINED(flags) ? '' : ToString(flags);
- var global = false;
- var ignoreCase = false;
- var multiline = false;
- var sticky = false;
- for (var i = 0; i < flags.length; i++) {
- var c = %_CallFunction(flags, i, StringCharAt);
- switch (c) {
- case 'g':
- if (global) {
- throw MakeSyntaxError("invalid_regexp_flags", [flags]);
- }
- global = true;
- break;
- case 'i':
- if (ignoreCase) {
- throw MakeSyntaxError("invalid_regexp_flags", [flags]);
- }
- ignoreCase = true;
- break;
- case 'm':
- if (multiline) {
- throw MakeSyntaxError("invalid_regexp_flags", [flags]);
- }
- multiline = true;
- break;
- case 'y':
- if (!harmony_regexps || sticky) {
- throw MakeSyntaxError("invalid_regexp_flags", [flags]);
- }
- sticky = true;
- break;
- default:
- throw MakeSyntaxError("invalid_regexp_flags", [flags]);
- }
- }
-
- %RegExpInitializeObject(object, pattern, global, ignoreCase, multiline, sticky);
-
- // Call internal function to compile the pattern.
- %RegExpCompile(object, pattern, flags);
+ %RegExpInitializeAndCompile(object, pattern, flags);
}
« no previous file with comments | « src/jsregexp.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698