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

Side by Side Diff: analyzer/lib/src/generated/interner.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « analyzer/lib/src/generated/incremental_scanner.dart ('k') | analyzer/lib/src/generated/java_core.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698