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) { |