| Index: sky/examples/fn/lib/style.dart
|
| diff --git a/sky/examples/fn/lib/style.dart b/sky/examples/fn/lib/style.dart
|
| index c89db5e73dda9228af18f74fe01c5b6ad2c14744..4dd510f7280f0623fc47def9e51b10ee70705b10 100644
|
| --- a/sky/examples/fn/lib/style.dart
|
| +++ b/sky/examples/fn/lib/style.dart
|
| @@ -1,17 +1,21 @@
|
| +// 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.
|
| +
|
| part of fn;
|
|
|
| class Style {
|
| final String _className;
|
| - static Map<String, Style> _cache = null;
|
| + static final Map<String, Style> _cache = new HashMap<String, Style>();
|
|
|
| static int nextStyleId = 1;
|
|
|
| static String nextClassName(String styles) {
|
| assert(sky.document != null);
|
| - var className = "style$nextStyleId";
|
| + String className = "style$nextStyleId";
|
| nextStyleId++;
|
|
|
| - var styleNode = sky.document.createElement('style');
|
| + sky.Element styleNode = sky.document.createElement('style');
|
| styleNode.setChild(new sky.Text(".$className { $styles }"));
|
| sky.document.appendChild(styleNode);
|
|
|
| @@ -19,17 +23,9 @@ class Style {
|
| }
|
|
|
| factory Style(String styles) {
|
| - if (_cache == null) {
|
| - _cache = new HashMap<String, Style>();
|
| - }
|
| -
|
| - var style = _cache[styles];
|
| - if (style == null) {
|
| - style = new Style._internal(nextClassName(styles));
|
| - _cache[styles] = style;
|
| - }
|
| -
|
| - return style;
|
| + return _cache.putIfAbsent(styles, () {
|
| + return new Style._internal(nextClassName(styles));
|
| + });
|
| }
|
|
|
| Style._internal(this._className);
|
|
|