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

Unified Diff: sky/examples/fn/lib/reflect.dart

Issue 973613004: Clean up some Dart idioms in fn (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 | « sky/examples/fn/lib/node.dart ('k') | sky/examples/fn/lib/style.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/fn/lib/reflect.dart
diff --git a/sky/examples/fn/lib/reflect.dart b/sky/examples/fn/lib/reflect.dart
index 66b2efefc2ea698c86a7c7cd98819750f054157c..99dcaa7c394577a6f1b3c5d976e6bd0e817a1545 100644
--- a/sky/examples/fn/lib/reflect.dart
+++ b/sky/examples/fn/lib/reflect.dart
@@ -1,15 +1,17 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
library reflect;
import 'dart:mirrors';
import 'dart:collection';
-HashMap<ClassMirror, List> _fieldCache = new HashMap<ClassMirror, List>();
+final HashMap<ClassMirror, List> _fieldCache = new HashMap<ClassMirror, List>();
List<Symbol> _getPublicFields(ClassMirror mirror) {
- var fields = _fieldCache[mirror];
- if (fields == null) {
- fields = new List<Symbol>();
- _fieldCache[mirror] = fields;
+ return _fieldCache.putIfAbsent(mirror, () {
+ List<Symbol> fields = new List<Symbol>();
while (mirror != null) {
var decls = mirror.declarations;
@@ -25,9 +27,9 @@ List<Symbol> _getPublicFields(ClassMirror mirror) {
mirror = mirror.superclass;
}
- }
- return fields;
+ return fields;
+ });
}
void copyPublicFields(Object source, Object target) {
« no previous file with comments | « sky/examples/fn/lib/node.dart ('k') | sky/examples/fn/lib/style.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698