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

Unified Diff: runtime/vm/parser.cc

Issue 14023005: Do not allocate unnecessary ObjectArrays. When allocating an empty growable array, pass it just a… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 21373)
+++ runtime/vm/parser.cc (working copy)
@@ -8796,9 +8796,18 @@
}
factory_type_args = factory_type_args.Canonicalize();
ArgumentListNode* factory_param = new ArgumentListNode(literal_pos);
- const LocalVariable& temp_local = *BuildArrayTempLocal(type_pos);
- ArrayNode* list = new ArrayNode(TokenPos(), type, temp_local, element_list);
- factory_param->Add(list);
+ if (element_list.length() == 0) {
+ // TODO(srdjan): Use Object::empty_array once issue 9871 has been fixed.
+ Array& empty_array = Array::ZoneHandle(Object::empty_array().raw());
+ LiteralNode* empty_array_literal =
+ new LiteralNode(TokenPos(), empty_array);
+ factory_param->Add(empty_array_literal);
+ } else {
+ const LocalVariable& temp_local = *BuildArrayTempLocal(type_pos);
+ ArrayNode* list =
+ new ArrayNode(TokenPos(), type, temp_local, element_list);
+ factory_param->Add(list);
+ }
return CreateConstructorCallNode(literal_pos,
factory_type_args,
factory_method,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698