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

Unified Diff: runtime/vm/object.h

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
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 38066)
+++ runtime/vm/object.h (working copy)
@@ -6028,6 +6028,11 @@
static RawArray* New(intptr_t len, Heap::Space space = Heap::kNew);
+ // Empty array is read-only. Use only for arrays without type arguments.
+ static RawArray* NewOrEmpty(intptr_t len, Heap::Space space = Heap::kNew) {
+ return (len == 0) ? empty_array().raw() : New(len, space);
+ }
siva 2014/07/09 20:08:03 may not need this if you do the explicit checks in
+
// Creates and returns a new array with 'new_length'. Copies all elements from
// 'source' to the new array. 'new_length' must be greater than or equal to
// 'source.Length()'. 'source' can be null.

Powered by Google App Engine
This is Rietveld 408576698