OLD | NEW |
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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 case FP_ZERO: | 762 case FP_ZERO: |
763 builder.AddCharacter('0'); | 763 builder.AddCharacter('0'); |
764 break; | 764 break; |
765 | 765 |
766 default: { | 766 default: { |
767 int decimal_point; | 767 int decimal_point; |
768 int sign; | 768 int sign; |
769 | 769 |
770 char* decimal_rep; | 770 char* decimal_rep; |
771 bool used_gay_dtoa = false; | 771 bool used_gay_dtoa = false; |
772 char fast_dtoa_buffer[kFastDtoaMaximalLength + 1]; | 772 const int kFastDtoaBufferCapacity = kFastDtoaMaximalLength + 1; |
| 773 char fast_dtoa_buffer[kFastDtoaBufferCapacity]; |
773 int length; | 774 int length; |
774 if (FastDtoa(v, fast_dtoa_buffer, &sign, &length, &decimal_point)) { | 775 if (FastDtoa(v, Vector<char>(fast_dtoa_buffer, kFastDtoaBufferCapacity), |
| 776 &sign, &length, &decimal_point)) { |
775 decimal_rep = fast_dtoa_buffer; | 777 decimal_rep = fast_dtoa_buffer; |
776 } else { | 778 } else { |
777 decimal_rep = dtoa(v, 0, 0, &decimal_point, &sign, NULL); | 779 decimal_rep = dtoa(v, 0, 0, &decimal_point, &sign, NULL); |
778 used_gay_dtoa = true; | 780 used_gay_dtoa = true; |
779 length = StrLength(decimal_rep); | 781 length = StrLength(decimal_rep); |
780 } | 782 } |
781 | 783 |
782 if (sign) builder.AddCharacter('-'); | 784 if (sign) builder.AddCharacter('-'); |
783 | 785 |
784 if (length <= decimal_point && decimal_point <= 21) { | 786 if (length <= decimal_point && decimal_point <= 21) { |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 // Allocate result and fill in the parts. | 1096 // Allocate result and fill in the parts. |
1095 StringBuilder builder(result_size + 1); | 1097 StringBuilder builder(result_size + 1); |
1096 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size); | 1098 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size); |
1097 if (decimal_pos > 0) builder.AddCharacter('.'); | 1099 if (decimal_pos > 0) builder.AddCharacter('.'); |
1098 builder.AddSubstring(decimal_buffer, decimal_pos); | 1100 builder.AddSubstring(decimal_buffer, decimal_pos); |
1099 return builder.Finalize(); | 1101 return builder.Finalize(); |
1100 } | 1102 } |
1101 | 1103 |
1102 | 1104 |
1103 } } // namespace v8::internal | 1105 } } // namespace v8::internal |
OLD | NEW |