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

Side by Side Diff: src/math.js

Issue 519061: Improve performance of Array.prototype.join and String.prototype.substring... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 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 | Annotate | Revision Log
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // ECMA 262 - 15.8.2.9 96 // ECMA 262 - 15.8.2.9
97 function MathFloor(x) { 97 function MathFloor(x) {
98 if (!IS_NUMBER(x)) x = ToNumber(x); 98 if (!IS_NUMBER(x)) x = ToNumber(x);
99 // It's more common to call this with a positive number that's out 99 // It's more common to call this with a positive number that's out
100 // of range than negative numbers; check the upper bound first. 100 // of range than negative numbers; check the upper bound first.
101 if (x < 0x80000000 && x > 0) { 101 if (x < 0x80000000 && x > 0) {
102 // Numbers in the range [0, 2^31) can be floored by converting 102 // Numbers in the range [0, 2^31) can be floored by converting
103 // them to an unsigned 32-bit value using the shift operator. 103 // them to an unsigned 32-bit value using the shift operator.
104 // We avoid doing so for -0, because the result of Math.floor(-0) 104 // We avoid doing so for -0, because the result of Math.floor(-0)
105 // has to be -0, which wouldn't be the case with the shift. 105 // has to be -0, which wouldn't be the case with the shift.
106 return x << 0; 106 return TO_UINT32(x);
107 } else { 107 } else {
108 return %Math_floor(x); 108 return %Math_floor(x);
109 } 109 }
110 } 110 }
111 111
112 // ECMA 262 - 15.8.2.10 112 // ECMA 262 - 15.8.2.10
113 function MathLog(x) { 113 function MathLog(x) {
114 if (!IS_NUMBER(x)) x = ToNumber(x); 114 if (!IS_NUMBER(x)) x = ToNumber(x);
115 return %Math_log(x); 115 return %Math_log(x);
116 } 116 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 "tan", MathTan, 254 "tan", MathTan,
255 "atan2", MathAtan2, 255 "atan2", MathAtan2,
256 "pow", MathPow, 256 "pow", MathPow,
257 "max", MathMax, 257 "max", MathMax,
258 "min", MathMin 258 "min", MathMin
259 )); 259 ));
260 }; 260 };
261 261
262 262
263 SetupMath(); 263 SetupMath();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698