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

Unified Diff: src/runtime.cc

Issue 42280: Made Date parser work on flat strings instead of arbitrary ones. (Closed)
Patch Set: Created 11 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 side-by-side diff with in-line comments
Download patch
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 134fddf114d0f22dab922198cbb6b4d5c94b8015..940c89d6c76f6e86e8b8a4a6ccd72cf02c9c741d 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -4484,8 +4484,19 @@ static Object* Runtime_DateParseString(Arguments args) {
CONVERT_CHECKED(String, string_object, args[0]);
Handle<String> str(string_object);
+ FlattenString(str);
Handle<FixedArray> output = Factory::NewFixedArray(DateParser::OUTPUT_SIZE);
- if (DateParser::Parse(*str, *output)) {
+ bool result;
+ {
+ AssertNoAllocation no_allocation;
+ if (StringShape(*str).IsAsciiRepresentation()) {
+ result = DateParser::Parse(str->ToAsciiVector(), *output);
+ } else {
+ ASSERT(StringShape(*str).IsTwoByteRepresentation());
+ result = DateParser::Parse(str->ToUC16Vector(), *output);
+ }
+ }
+ if (result) {
return *Factory::NewJSArrayWithElements(output);
} else {
return *Factory::null_value();

Powered by Google App Engine
This is Rietveld 408576698