| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 // Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file |  | 
| 2 // for details. All rights reserved. Use of this source code is governed by a |  | 
| 3 // BSD-style license that can be found in the LICENSE file. |  | 
| 4 |  | 
| 5 library interner; |  | 
| 6 |  | 
| 7 import 'dart:collection'; |  | 
| 8 |  | 
| 9 /** |  | 
| 10  * The interface `Interner` defines the behavior of objects that can intern |  | 
| 11  * strings. |  | 
| 12  */ |  | 
| 13 abstract class Interner { |  | 
| 14   /** |  | 
| 15    * Return a string that is identical to all of the other strings that have |  | 
| 16    * been interned that are equal to the given [string]. |  | 
| 17    */ |  | 
| 18   String intern(String string); |  | 
| 19 } |  | 
| 20 |  | 
| 21 /** |  | 
| 22  * The class `MappedInterner` implements an interner that uses a map to manage |  | 
| 23  * the strings that have been interned. |  | 
| 24  */ |  | 
| 25 class MappedInterner implements Interner { |  | 
| 26   /** |  | 
| 27    * A table mapping strings to themselves. |  | 
| 28    */ |  | 
| 29   Map<String, String> _table = new HashMap<String, String>(); |  | 
| 30 |  | 
| 31   @override |  | 
| 32   String intern(String string) { |  | 
| 33     String original = _table[string]; |  | 
| 34     if (original == null) { |  | 
| 35       _table[string] = string; |  | 
| 36       return string; |  | 
| 37     } |  | 
| 38     return original; |  | 
| 39   } |  | 
| 40 } |  | 
| 41 |  | 
| 42 /** |  | 
| 43  * The class `NullInterner` implements an interner that does nothing (does not |  | 
| 44  * actually intern any strings). |  | 
| 45  */ |  | 
| 46 class NullInterner implements Interner { |  | 
| 47   @override |  | 
| 48   String intern(String string) => string; |  | 
| 49 } |  | 
| OLD | NEW | 
|---|