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

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

Issue 949733003: Share the JavaScript based LinkedHashMap implementation between constant maps and the LinkedHashMap… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 GeneralConstantMap(this._jsData) : super._(); 107 GeneralConstantMap(this._jsData) : super._();
108 108
109 // [_jsData] holds a key-value pair list. 109 // [_jsData] holds a key-value pair list.
110 final _jsData; 110 final _jsData;
111 111
112 // We cannot create the backing map on creation since hashCode interceptors 112 // We cannot create the backing map on creation since hashCode interceptors
113 // have not been defined when constants are created. 113 // have not been defined when constants are created.
114 Map<K, V> _getMap() { 114 Map<K, V> _getMap() {
115 LinkedHashMap<K, V> backingMap = JS('LinkedHashMap|Null', r'#.$map', this); 115 LinkedHashMap<K, V> backingMap = JS('LinkedHashMap|Null', r'#.$map', this);
116 if (backingMap == null) { 116 if (backingMap == null) {
117 backingMap = new LinkedHashMap<K, V>(); 117 backingMap = new JsLinkedHashMap<K, V>();
118 fillLiteralMap(_jsData, backingMap); 118 fillLiteralMap(_jsData, backingMap);
119 JS('', r'#.$map = #', this, backingMap); 119 JS('', r'#.$map = #', this, backingMap);
120 } 120 }
121 return backingMap; 121 return backingMap;
122 } 122 }
123 123
124 bool containsValue(V needle) { 124 bool containsValue(V needle) {
125 return _getMap().containsValue(needle); 125 return _getMap().containsValue(needle);
126 } 126 }
127 127
(...skipping 12 matching lines...) Expand all
140 Iterable<K> get keys { 140 Iterable<K> get keys {
141 return _getMap().keys; 141 return _getMap().keys;
142 } 142 }
143 143
144 Iterable<V> get values { 144 Iterable<V> get values {
145 return _getMap().values; 145 return _getMap().values;
146 } 146 }
147 147
148 int get length => _getMap().length; 148 int get length => _getMap().length;
149 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698