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

Unified Diff: src/conversions.cc

Issue 654763003: Flatten the string in StringToDouble function. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/conversions.h ('k') | src/lookup.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/conversions.cc
diff --git a/src/conversions.cc b/src/conversions.cc
index 8b776235e7b255a8638b954856bfcab159665a2f..663f4e8dec254c4126142dc2b5e628e5a8aad97c 100644
--- a/src/conversions.cc
+++ b/src/conversions.cc
@@ -483,19 +483,21 @@ char* DoubleToRadixCString(double value, int radix) {
}
-double StringToDouble(UnicodeCache* unicode_cache,
- String* string,
- int flags,
- double empty_string_val) {
- DisallowHeapAllocation no_gc;
- String::FlatContent flat = string->GetFlatContent();
- // ECMA-262 section 15.1.2.3, empty string is NaN
- if (flat.IsOneByte()) {
- return StringToDouble(
- unicode_cache, flat.ToOneByteVector(), flags, empty_string_val);
- } else {
- return StringToDouble(
- unicode_cache, flat.ToUC16Vector(), flags, empty_string_val);
+double StringToDouble(UnicodeCache* unicode_cache, Handle<String> string,
+ int flags, double empty_string_val) {
+ Handle<String> flattened = String::Flatten(string);
+ {
+ DisallowHeapAllocation no_gc;
+ String::FlatContent flat = flattened->GetFlatContent();
+ DCHECK(flat.IsFlat());
+ // ECMA-262 section 15.1.2.3, empty string is NaN
+ if (flat.IsOneByte()) {
+ return StringToDouble(unicode_cache, flat.ToOneByteVector(), flags,
+ empty_string_val);
+ } else {
+ return StringToDouble(unicode_cache, flat.ToUC16Vector(), flags,
+ empty_string_val);
+ }
}
}
« no previous file with comments | « src/conversions.h ('k') | src/lookup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698