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

Unified Diff: runtime/vm/ast.h

Issue 12207137: Reduce allocation of ArrayNode-s where a GrowableArray could be used instead. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 | runtime/vm/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast.h
===================================================================
--- runtime/vm/ast.h (revision 18405)
+++ runtime/vm/ast.h (working copy)
@@ -269,13 +269,19 @@
: AstNode(token_pos),
type_(type),
elements_() {
- ASSERT(type_.IsZoneHandle());
- ASSERT(!type_.IsNull());
- ASSERT(type_.IsFinalized());
- // Type may be uninstantiated when creating a generic list literal.
- ASSERT((type.arguments() == AbstractTypeArguments::null()) ||
- ((AbstractTypeArguments::Handle(type.arguments()).Length() == 1)));
+ CheckFields();
}
+ ArrayNode(intptr_t token_pos,
+ const AbstractType& type,
+ const GrowableArray<AstNode*>& elements)
+ : AstNode(token_pos),
+ type_(type),
+ elements_(elements.length()) {
+ CheckFields();
+ for (intptr_t i = 0; i < elements.length(); i++) {
+ elements_.Add(elements[i]);
+ }
+ }
void VisitChildren(AstNodeVisitor* visitor) const;
@@ -295,6 +301,15 @@
const AbstractType& type_;
GrowableArray<AstNode*> elements_;
+ void CheckFields() {
+ ASSERT(type_.IsZoneHandle());
+ ASSERT(!type_.IsNull());
+ ASSERT(type_.IsFinalized());
+ // Type may be uninstantiated when creating a generic list literal.
+ ASSERT((type_.arguments() == AbstractTypeArguments::null()) ||
+ ((AbstractTypeArguments::Handle(type_.arguments()).Length() == 1)));
+ }
+
DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayNode);
};
« no previous file with comments | « no previous file | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698