Chromium Code Reviews| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 leading_zero = true; | 288 leading_zero = true; |
| 289 ++current; | 289 ++current; |
| 290 if (current == end) return 0; | 290 if (current == end) return 0; |
| 291 } | 291 } |
| 292 | 292 |
| 293 int begin_pos = buffer_pos; | 293 int begin_pos = buffer_pos; |
| 294 while ((*current >= '0' && *current <= '9') | 294 while ((*current >= '0' && *current <= '9') |
| 295 || (*current >= 'a' && *current <= 'f') | 295 || (*current >= 'a' && *current <= 'f') |
| 296 || (*current >= 'A' && *current <= 'F')) { | 296 || (*current >= 'A' && *current <= 'F')) { |
| 297 if (significant_digits <= max_significant_digits) { | 297 if (significant_digits <= max_significant_digits) { |
| 298 ASSERT(buffer_pos < buffer_size); | |
|
Kasper Lund
2010/03/24 09:44:05
I would probably have preferred a solution where w
| |
| 299 buffer[buffer_pos++] = *current; | 298 buffer[buffer_pos++] = *current; |
| 300 significant_digits++; | 299 significant_digits++; |
| 301 } else { | 300 } else { |
| 302 insignificant_digits++; | 301 insignificant_digits++; |
| 303 nonzero_digit_dropped = nonzero_digit_dropped || *current != '0'; | 302 nonzero_digit_dropped = nonzero_digit_dropped || *current != '0'; |
| 304 } | 303 } |
| 305 ++current; | 304 ++current; |
| 306 if (current == end) break; | 305 if (current == end) break; |
| 307 } | 306 } |
| 308 | 307 |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 973 // Allocate result and fill in the parts. | 972 // Allocate result and fill in the parts. |
| 974 StringBuilder builder(result_size + 1); | 973 StringBuilder builder(result_size + 1); |
| 975 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size); | 974 builder.AddSubstring(integer_buffer + integer_pos + 1, integer_part_size); |
| 976 if (decimal_pos > 0) builder.AddCharacter('.'); | 975 if (decimal_pos > 0) builder.AddCharacter('.'); |
| 977 builder.AddSubstring(decimal_buffer, decimal_pos); | 976 builder.AddSubstring(decimal_buffer, decimal_pos); |
| 978 return builder.Finalize(); | 977 return builder.Finalize(); |
| 979 } | 978 } |
| 980 | 979 |
| 981 | 980 |
| 982 } } // namespace v8::internal | 981 } } // namespace v8::internal |
| OLD | NEW |