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

Unified Diff: runtime/vm/object.cc

Issue 381483002: Allocate fewer empty arrays. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 | « runtime/vm/flow_graph_compiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 38433)
+++ runtime/vm/object.cc (working copy)
@@ -6511,15 +6511,18 @@
count++;
}
}
-
- const Array& a = Array::Handle(Array::New(count, Heap::kOld));
- count = 0;
- for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
- if (deopt_id_to_ic_data[i] != NULL) {
- a.SetAt(count++, *deopt_id_to_ic_data[i]);
+ if (count == 0) {
+ set_ic_data_array(Object::empty_array());
+ } else {
+ const Array& a = Array::Handle(Array::New(count, Heap::kOld));
+ count = 0;
+ for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) {
+ if (deopt_id_to_ic_data[i] != NULL) {
+ a.SetAt(count++, *deopt_id_to_ic_data[i]);
+ }
}
+ set_ic_data_array(a);
}
- set_ic_data_array(a);
}
@@ -10699,7 +10702,8 @@
result ^= raw;
result.raw_ptr()->length_ = num_variables;
}
- const Array& names = Array::Handle(Array::New(num_variables, Heap::kOld));
+ const Array& names = (num_variables == 0) ? Object::empty_array() :
+ Array::Handle(Array::New(num_variables, Heap::kOld));
result.raw_ptr()->names_ = names.raw();
return result.raw();
}
@@ -10800,7 +10804,9 @@
result ^= raw;
result.raw_ptr()->length_ = num_handlers;
}
- const Array& handled_types_data = Array::Handle(Array::New(num_handlers));
+ const Array& handled_types_data = (num_handlers == 0) ?
+ Object::empty_array() :
+ Array::Handle(Array::New(num_handlers));
result.set_handled_types_data(handled_types_data);
return result.raw();
}
« no previous file with comments | « runtime/vm/flow_graph_compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698