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

Side by Side Diff: src/conversions.cc

Issue 1032007: Rename grisu to fast_dtoa. Get rid of template. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « src/SConscript ('k') | src/fast-dtoa.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdarg.h> 28 #include <stdarg.h>
29 29
30 #include "v8.h" 30 #include "v8.h"
31 31
32 #include "conversions-inl.h" 32 #include "conversions-inl.h"
33 #include "factory.h" 33 #include "factory.h"
34 #include "grisu3.h" 34 #include "fast-dtoa.h"
35 #include "scanner.h" 35 #include "scanner.h"
36 36
37 namespace v8 { 37 namespace v8 {
38 namespace internal { 38 namespace internal {
39 39
40 int HexValue(uc32 c) { 40 int HexValue(uc32 c) {
41 if ('0' <= c && c <= '9') 41 if ('0' <= c && c <= '9')
42 return c - '0'; 42 return c - '0';
43 if ('a' <= c && c <= 'f') 43 if ('a' <= c && c <= 'f')
44 return c - 'a' + 10; 44 return c - 'a' + 10;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 377
378 case FP_ZERO: 378 case FP_ZERO:
379 builder.AddCharacter('0'); 379 builder.AddCharacter('0');
380 break; 380 break;
381 381
382 default: { 382 default: {
383 int decimal_point; 383 int decimal_point;
384 int sign; 384 int sign;
385 385
386 char* decimal_rep; 386 char* decimal_rep;
387 bool used_dtoa = false; 387 bool used_gay_dtoa = false;
388 char grisu_buffer[kGrisu3MaximalLength + 1]; 388 char fast_dtoa_buffer[kFastDtoaMaximalLength + 1];
389 int length; 389 int length;
390 if (grisu3(v, grisu_buffer, &sign, &length, &decimal_point)) { 390 if (FastDtoa(v, fast_dtoa_buffer, &sign, &length, &decimal_point)) {
391 decimal_rep = grisu_buffer; 391 decimal_rep = fast_dtoa_buffer;
392 } else { 392 } else {
393 decimal_rep = dtoa(v, 0, 0, &decimal_point, &sign, NULL); 393 decimal_rep = dtoa(v, 0, 0, &decimal_point, &sign, NULL);
394 used_dtoa = true; 394 used_gay_dtoa = true;
395 length = StrLength(decimal_rep); 395 length = StrLength(decimal_rep);
396 } 396 }
397 397
398 if (sign) builder.AddCharacter('-'); 398 if (sign) builder.AddCharacter('-');
399 399
400 if (length <= decimal_point && decimal_point <= 21) { 400 if (length <= decimal_point && decimal_point <= 21) {
401 // ECMA-262 section 9.8.1 step 6. 401 // ECMA-262 section 9.8.1 step 6.
402 builder.AddString(decimal_rep); 402 builder.AddString(decimal_rep);
403 builder.AddPadding('0', decimal_point - length); 403 builder.AddPadding('0', decimal_point - length);
404 404
(...skipping 16 matching lines...) Expand all
421 builder.AddCharacter('.'); 421 builder.AddCharacter('.');
422 builder.AddString(decimal_rep + 1); 422 builder.AddString(decimal_rep + 1);
423 } 423 }
424 builder.AddCharacter('e'); 424 builder.AddCharacter('e');
425 builder.AddCharacter((decimal_point >= 0) ? '+' : '-'); 425 builder.AddCharacter((decimal_point >= 0) ? '+' : '-');
426 int exponent = decimal_point - 1; 426 int exponent = decimal_point - 1;
427 if (exponent < 0) exponent = -exponent; 427 if (exponent < 0) exponent = -exponent;
428 builder.AddFormatted("%d", exponent); 428 builder.AddFormatted("%d", exponent);
429 } 429 }
430 430
431 if (used_dtoa) freedtoa(decimal_rep); 431 if (used_gay_dtoa) freedtoa(decimal_rep);
432 } 432 }
433 } 433 }
434 return builder.Finalize(); 434 return builder.Finalize();
435 } 435 }
436 436
437 437
438 const char* IntToCString(int n, Vector<char> buffer) { 438 const char* IntToCString(int n, Vector<char> buffer) {
439 bool negative = false; 439 bool negative = false;
440 if (n < 0) { 440 if (n < 0) {
441 // We must not negate the most negative int. 441 // We must not negate the most negative int.
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 // Allocate result and fill in the parts. 710 // Allocate result and fill in the parts.
711 StringBuilder builder(result_size + 1); 711 StringBuilder builder(result_size + 1);
712 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size); 712 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size);
713 if (decimal_pos > 0) builder.AddCharacter('.'); 713 if (decimal_pos > 0) builder.AddCharacter('.');
714 builder.AddSubstring(decimal_buffer, decimal_pos); 714 builder.AddSubstring(decimal_buffer, decimal_pos);
715 return builder.Finalize(); 715 return builder.Finalize();
716 } 716 }
717 717
718 718
719 } } // namespace v8::internal 719 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/SConscript ('k') | src/fast-dtoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698