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

Side by Side Diff: runtime/vm/double_conversion.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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
« no previous file with comments | « runtime/vm/disassembler_x64.cc ('k') | runtime/vm/dwarf.cc » ('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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/double_conversion.h" 5 #include "vm/double_conversion.h"
6 6
7 #include "third_party/double-conversion/src/double-conversion.h" 7 #include "third_party/double-conversion/src/double-conversion.h"
8 8
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 0, 0); // Last four values are ignored in fixed mode. 83 0, 0); // Last four values are ignored in fixed mode.
84 84
85 char* buffer = Thread::Current()->zone()->Alloc<char>(kBufferSize); 85 char* buffer = Thread::Current()->zone()->Alloc<char>(kBufferSize);
86 buffer[kBufferSize - 1] = '\0'; 86 buffer[kBufferSize - 1] = '\0';
87 double_conversion::StringBuilder builder(buffer, kBufferSize); 87 double_conversion::StringBuilder builder(buffer, kBufferSize);
88 bool status = converter.ToFixed(d, fraction_digits, &builder); 88 bool status = converter.ToFixed(d, fraction_digits, &builder);
89 ASSERT(status); 89 ASSERT(status);
90 return String::New(builder.Finalize()); 90 return String::New(builder.Finalize());
91 } 91 }
92 92
93
94 RawString* DoubleToStringAsExponential(double d, int fraction_digits) { 93 RawString* DoubleToStringAsExponential(double d, int fraction_digits) {
95 static const int kMinFractionDigits = -1; // -1 represents shortest mode. 94 static const int kMinFractionDigits = -1; // -1 represents shortest mode.
96 static const int kMaxFractionDigits = 20; 95 static const int kMaxFractionDigits = 20;
97 static const int kConversionFlags = 96 static const int kConversionFlags =
98 double_conversion::DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN; 97 double_conversion::DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
99 const int kBufferSize = 128; 98 const int kBufferSize = 128;
100 99
101 USE(kMinFractionDigits); 100 USE(kMinFractionDigits);
102 USE(kMaxFractionDigits); 101 USE(kMaxFractionDigits);
103 // The output contains the sign, at most 1 digits, the decimal point followed 102 // The output contains the sign, at most 1 digits, the decimal point followed
(...skipping 10 matching lines...) Expand all
114 0, 0); // Last four values are ignored in exponential mode. 113 0, 0); // Last four values are ignored in exponential mode.
115 114
116 char* buffer = Thread::Current()->zone()->Alloc<char>(kBufferSize); 115 char* buffer = Thread::Current()->zone()->Alloc<char>(kBufferSize);
117 buffer[kBufferSize - 1] = '\0'; 116 buffer[kBufferSize - 1] = '\0';
118 double_conversion::StringBuilder builder(buffer, kBufferSize); 117 double_conversion::StringBuilder builder(buffer, kBufferSize);
119 bool status = converter.ToExponential(d, fraction_digits, &builder); 118 bool status = converter.ToExponential(d, fraction_digits, &builder);
120 ASSERT(status); 119 ASSERT(status);
121 return String::New(builder.Finalize()); 120 return String::New(builder.Finalize());
122 } 121 }
123 122
124
125 RawString* DoubleToStringAsPrecision(double d, int precision) { 123 RawString* DoubleToStringAsPrecision(double d, int precision) {
126 static const int kMinPrecisionDigits = 1; 124 static const int kMinPrecisionDigits = 1;
127 static const int kMaxPrecisionDigits = 21; 125 static const int kMaxPrecisionDigits = 21;
128 static const int kMaxLeadingPaddingZeroes = 6; 126 static const int kMaxLeadingPaddingZeroes = 6;
129 static const int kMaxTrailingPaddingZeroes = 0; 127 static const int kMaxTrailingPaddingZeroes = 0;
130 static const int kConversionFlags = 128 static const int kConversionFlags =
131 double_conversion::DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN; 129 double_conversion::DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
132 const int kBufferSize = 128; 130 const int kBufferSize = 128;
133 131
134 USE(kMinPrecisionDigits); 132 USE(kMinPrecisionDigits);
(...skipping 16 matching lines...) Expand all
151 kMaxLeadingPaddingZeroes, kMaxTrailingPaddingZeroes); 149 kMaxLeadingPaddingZeroes, kMaxTrailingPaddingZeroes);
152 150
153 char* buffer = Thread::Current()->zone()->Alloc<char>(kBufferSize); 151 char* buffer = Thread::Current()->zone()->Alloc<char>(kBufferSize);
154 buffer[kBufferSize - 1] = '\0'; 152 buffer[kBufferSize - 1] = '\0';
155 double_conversion::StringBuilder builder(buffer, kBufferSize); 153 double_conversion::StringBuilder builder(buffer, kBufferSize);
156 bool status = converter.ToPrecision(d, precision, &builder); 154 bool status = converter.ToPrecision(d, precision, &builder);
157 ASSERT(status); 155 ASSERT(status);
158 return String::New(builder.Finalize()); 156 return String::New(builder.Finalize());
159 } 157 }
160 158
161
162 bool CStringToDouble(const char* str, intptr_t length, double* result) { 159 bool CStringToDouble(const char* str, intptr_t length, double* result) {
163 if (length == 0) { 160 if (length == 0) {
164 return false; 161 return false;
165 } 162 }
166 163
167 double_conversion::StringToDoubleConverter converter( 164 double_conversion::StringToDoubleConverter converter(
168 double_conversion::StringToDoubleConverter::NO_FLAGS, 0.0, 0.0, 165 double_conversion::StringToDoubleConverter::NO_FLAGS, 0.0, 0.0,
169 kDoubleToStringCommonInfinitySymbol, kDoubleToStringCommonNaNSymbol); 166 kDoubleToStringCommonInfinitySymbol, kDoubleToStringCommonNaNSymbol);
170 167
171 int parsed_count = 0; 168 int parsed_count = 0;
172 *result = 169 *result =
173 converter.StringToDouble(str, static_cast<int>(length), &parsed_count); 170 converter.StringToDouble(str, static_cast<int>(length), &parsed_count);
174 return (parsed_count == length); 171 return (parsed_count == length);
175 } 172 }
176 173
177
178 } // namespace dart 174 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/disassembler_x64.cc ('k') | runtime/vm/dwarf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698