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

Side by Side Diff: src/v8natives.js

Issue 48061: Remapped regexp last-match-info to put subject and index before match indices. (Closed)
Patch Set: Created 11 years, 9 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 // ECMA 262 - 15.1.5 68 // ECMA 262 - 15.1.5
69 function GlobalIsFinite(number) { 69 function GlobalIsFinite(number) {
70 return %NumberIsFinite(ToNumber(number)); 70 return %NumberIsFinite(ToNumber(number));
71 } 71 }
72 72
73 73
74 // ECMA-262 - 15.1.2.2 74 // ECMA-262 - 15.1.2.2
75 function GlobalParseInt(string, radix) { 75 function GlobalParseInt(string, radix) {
76 if (radix === void 0) { 76 if (radix === void 0) {
77 radix = 0;
78 // Some people use parseInt instead of Math.floor. This 77 // Some people use parseInt instead of Math.floor. This
79 // optimization makes parseInt on a Smi 12 times faster (60ns 78 // optimization makes parseInt on a Smi 12 times faster (60ns
80 // vs 800ns). The following optimization makes parseInt on a 79 // vs 800ns). The following optimization makes parseInt on a
81 // non-Smi number 9 times faster (230ns vs 2070ns). Together 80 // non-Smi number 9 times faster (230ns vs 2070ns). Together
82 // they make parseInt on a string 1.4% slower (274ns vs 270ns). 81 // they make parseInt on a string 1.4% slower (274ns vs 270ns).
83 if (%_IsSmi(string)) return string; 82 if (%_IsSmi(string)) return string;
84 if (IS_NUMBER(string) && 83 if (IS_NUMBER(string) &&
85 ((string < -0.01 && -1e9 < string) || 84 ((string < -0.01 && -1e9 < string) ||
86 (0.01 < string && string < 1e9))) { 85 (0.01 < string && string < 1e9))) {
87 // Truncate number. 86 // Truncate number.
88 return string | 0; 87 return string | 0;
89 } 88 }
89 radix = 0;
90 } else { 90 } else {
91 radix = TO_INT32(radix); 91 radix = TO_INT32(radix);
92 if (!(radix == 0 || (2 <= radix && radix <= 36))) 92 if (!(radix == 0 || (2 <= radix && radix <= 36)))
93 return $NaN; 93 return $NaN;
94 } 94 }
95 return %StringParseInt(ToString(string), radix); 95 return %StringParseInt(ToString(string), radix);
96 } 96 }
97 97
98 98
99 // ECMA-262 - 15.1.2.3 99 // ECMA-262 - 15.1.2.3
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // ---------------------------------------------------------------------------- 531 // ----------------------------------------------------------------------------
532 532
533 function SetupFunction() { 533 function SetupFunction() {
534 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 534 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
535 "toString", FunctionToString 535 "toString", FunctionToString
536 )); 536 ));
537 } 537 }
538 538
539 SetupFunction(); 539 SetupFunction();
540 540
OLDNEW
« src/regexp-delay.js ('K') | « src/string.js ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698