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

Unified Diff: runtime/vm/parser.cc

Issue 1873143003: - Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list a… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review Created 4 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
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 6848e74497ae76201ed9492029a75659e475ea37..1e9f97f8b83387980c4fec9a7aa54c87acfc620b 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -12062,7 +12062,7 @@ RawInstance* Parser::TryCanonicalize(const Instance& instance,
}
const char* error_str = NULL;
Instance& result =
- Instance::Handle(Z, instance.CheckAndCanonicalize(&error_str));
+ Instance::Handle(Z, instance.CheckAndCanonicalize(thread(), &error_str));
if (result.IsNull()) {
ReportError(token_pos, "Invalid const object %s", error_str);
}
@@ -12747,6 +12747,9 @@ AstNode* Parser::ParseListLiteral(TokenPosition type_pos,
if (is_const) {
// Allocate and initialize the const list at compile time.
+ if ((element_list.length() == 0) && list_type_arguments.IsNull()) {
+ return new(Z) LiteralNode(literal_pos, Object::empty_array());
+ }
Array& const_list = Array::ZoneHandle(Z,
Array::New(element_list.length(), Heap::kOld));
const_list.SetTypeArguments(

Powered by Google App Engine
This is Rietveld 408576698