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

Side by Side Diff: pkg/front_end/lib/src/scanner/interner.dart

Issue 2486873003: Move scanner into pkg/front_end/lib/src/scanner. (Closed)
Patch Set: Created 4 years, 1 month 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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
Brian Wilkerson 2016/11/08 20:53:23 We should be consistent about updating or not upda
Paul Berry 2016/11/08 21:47:06 The only value I see in updating it is that as fil
Brian Wilkerson 2016/11/08 22:01:23 In that case, you missed two files. :-) (Hence the
Paul Berry 2016/11/08 22:06:02 Whoops, thank you. Please see https://codereview.
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.generated.interner; 5 library front_end.src.scanner.interner;
6
7 import 'dart:collection';
8 6
9 /** 7 /**
10 * The interface `Interner` defines the behavior of objects that can intern 8 * The interface `Interner` defines the behavior of objects that can intern
11 * strings. 9 * strings.
12 */ 10 */
13 abstract class Interner { 11 abstract class Interner {
14 /** 12 /**
15 * Return a string that is identical to all of the other strings that have 13 * Return a string that is identical to all of the other strings that have
16 * been interned that are equal to the given [string]. 14 * been interned that are equal to the given [string].
17 */ 15 */
18 String intern(String string); 16 String intern(String string);
19 } 17 }
20 18
21 /** 19 /**
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 20 * The class `NullInterner` implements an interner that does nothing (does not
44 * actually intern any strings). 21 * actually intern any strings).
45 */ 22 */
46 class NullInterner implements Interner { 23 class NullInterner implements Interner {
47 @override 24 @override
48 String intern(String string) => string; 25 String intern(String string) => string;
49 } 26 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698