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

Unified Diff: src/runtime.cc

Issue 50004: * Made Date string parser reuse the same output array each time. (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
« no previous file with comments | « src/runtime.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 746810adc248c3d68c1e1c56bfc939b8a48b6c49..34a5fcbf70d82701105df218f86338c7da9b4afd 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -4480,27 +4480,30 @@ static Object* Runtime_DateCurrentTime(Arguments args) {
static Object* Runtime_DateParseString(Arguments args) {
HandleScope scope;
- ASSERT(args.length() == 1);
-
- CONVERT_CHECKED(String, string_object, args[0]);
+ ASSERT(args.length() == 2);
- Handle<String> str(string_object);
+ CONVERT_ARG_CHECKED(String, str, 0);
FlattenString(str);
- Handle<FixedArray> output = Factory::NewFixedArray(DateParser::OUTPUT_SIZE);
+
+ CONVERT_ARG_CHECKED(JSArray, output, 1);
+ RUNTIME_ASSERT(output->HasFastElements());
+
+ AssertNoAllocation no_allocation;
+
+ FixedArray* output_array = output->elements();
+ RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE);
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 (StringShape(*str).IsAsciiRepresentation()) {
+ result = DateParser::Parse(str->ToAsciiVector(), output_array);
+ } else {
+ ASSERT(StringShape(*str).IsTwoByteRepresentation());
+ result = DateParser::Parse(str->ToUC16Vector(), output_array);
}
+
if (result) {
- return *Factory::NewJSArrayWithElements(output);
+ return *output;
} else {
- return *Factory::null_value();
+ return Heap::null_value();
}
}
« no previous file with comments | « src/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698