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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/constant_map.dart

Issue 1104063002: Make EfficientLength public, as EfficientLengthIterable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 5 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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 part of _js_helper; 5 part of _js_helper;
6 6
7 abstract class ConstantMap<K, V> implements Map<K, V> { 7 abstract class ConstantMap<K, V> implements Map<K, V> {
8 const ConstantMap._(); 8 const ConstantMap._();
9 9
10 bool get isEmpty => length == 0; 10 bool get isEmpty => length == 0;
11 11
12 bool get isNotEmpty => !isEmpty; 12 bool get isNotEmpty => !isEmpty;
13 13
14 String toString() => Maps.mapToString(this); 14 String toString() => Maps.mapToString(this);
15 15
16 _throwUnmodifiable() { 16 _throwUnmodifiable() {
17 throw new UnsupportedError("Cannot modify unmodifiable Map"); 17 throw new UnsupportedError("Cannot modify unmodifiable Map");
18 } 18 }
19 void operator []=(K key, V val) => _throwUnmodifiable(); 19 void operator []=(K key, V val) => _throwUnmodifiable();
20 V putIfAbsent(K key, V ifAbsent()) => _throwUnmodifiable(); 20 V putIfAbsent(K key, V ifAbsent()) => _throwUnmodifiable();
21 V remove(K key) => _throwUnmodifiable(); 21 V remove(K key) => _throwUnmodifiable();
22 void clear() => _throwUnmodifiable(); 22 void clear() => _throwUnmodifiable();
23 void addAll(Map<K, V> other) => _throwUnmodifiable(); 23 void addAll(Map<K, V> other) => _throwUnmodifiable();
24 } 24 }
25 25
26 class ConstantStringMap<K, V> extends ConstantMap<K, V> 26 class ConstantStringMap<K, V> extends ConstantMap<K, V> {
27 implements _symbol_dev.EfficientLength {
28 27
29 // This constructor is not used. The instantiation is shortcut by the 28 // This constructor is not used. The instantiation is shortcut by the
30 // compiler. It is here to make the uninitialized final fields legal. 29 // compiler. It is here to make the uninitialized final fields legal.
31 const ConstantStringMap._(this.length, this._jsObject, this._keys) 30 const ConstantStringMap._(this.length, this._jsObject, this._keys)
32 : super._(); 31 : super._();
33 32
34 final int length; 33 final int length;
35 // A constant map is backed by a JavaScript object. 34 // A constant map is backed by a JavaScript object.
36 final _jsObject; 35 final _jsObject;
37 final List<K> _keys; 36 final List<K> _keys;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 Iterable<K> get keys { 139 Iterable<K> get keys {
141 return _getMap().keys; 140 return _getMap().keys;
142 } 141 }
143 142
144 Iterable<V> get values { 143 Iterable<V> get values {
145 return _getMap().values; 144 return _getMap().values;
146 } 145 }
147 146
148 int get length => _getMap().length; 147 int get length => _getMap().length;
149 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698