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

Side by Side Diff: pkg/compiler/lib/src/universe/function_set.dart

Issue 2941033002: Finish strong mode cleaning of dart2js. (Closed)
Patch Set: Add bug numbers and address comments. Created 3 years, 6 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
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 library universe.function_set; 5 library universe.function_set;
6 6
7 import '../common/names.dart' show Identifiers, Selectors; 7 import '../common/names.dart' show Identifiers, Selectors;
8 import '../elements/entities.dart'; 8 import '../elements/entities.dart';
9 import '../types/types.dart'; 9 import '../types/types.dart';
10 import '../util/util.dart' show Hashing, Setlet; 10 import '../util/util.dart' show Hashing, Setlet;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 assert(element.name == name); 171 assert(element.name == name);
172 // We try to avoid clearing the cache unless we have to. For that 172 // We try to avoid clearing the cache unless we have to. For that
173 // reason we keep the explicit contains check even though the add 173 // reason we keep the explicit contains check even though the add
174 // method ends up doing the work again (for sets). 174 // method ends up doing the work again (for sets).
175 if (!elements.contains(element)) { 175 if (!elements.contains(element)) {
176 if (isList && elements.length >= MAX_ELEMENTS_IN_LIST) { 176 if (isList && elements.length >= MAX_ELEMENTS_IN_LIST) {
177 elements = elements.toSet(); 177 elements = elements.toSet();
178 isList = false; 178 isList = false;
179 } 179 }
180 if (isList) { 180 if (isList) {
181 List list = elements; 181 List<MemberEntity> list = elements;
182 list.add(element); 182 list.add(element);
183 } else { 183 } else {
184 Set set = elements; 184 Set<MemberEntity> set = elements;
185 set.add(element); 185 set.add(element);
186 } 186 }
187 if (!cache.isEmpty) cache.clear(); 187 if (!cache.isEmpty) cache.clear();
188 } 188 }
189 } 189 }
190 190
191 void remove(MemberEntity element) { 191 void remove(MemberEntity element) {
192 assert(element.name == name); 192 assert(element.name == name);
193 if (isList) { 193 if (isList) {
194 List list = elements; 194 List<MemberEntity> list = elements;
195 int index = list.indexOf(element); 195 int index = list.indexOf(element);
196 if (index < 0) return; 196 if (index < 0) return;
197 MemberEntity last = list.removeLast(); 197 MemberEntity last = list.removeLast();
198 if (index != list.length) { 198 if (index != list.length) {
199 list[index] = last; 199 list[index] = last;
200 } 200 }
201 if (!cache.isEmpty) cache.clear(); 201 if (!cache.isEmpty) cache.clear();
202 } else { 202 } else {
203 Set set = elements; 203 Set<MemberEntity> set = elements;
204 if (set.remove(element)) { 204 if (set.remove(element)) {
205 // To avoid wobbling between the two representations, we do 205 // To avoid wobbling between the two representations, we do
206 // not transition back to the list representation even if we 206 // not transition back to the list representation even if we
207 // end up with few enough elements at this point. 207 // end up with few enough elements at this point.
208 if (!cache.isEmpty) cache.clear(); 208 if (!cache.isEmpty) cache.clear();
209 } 209 }
210 } 210 }
211 } 211 }
212 212
213 bool contains(MemberEntity element) { 213 bool contains(MemberEntity element) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } else if (closedWorld.isInstantiated(cls)) { 309 } else if (closedWorld.isInstantiated(cls)) {
310 return new TypeMask.nonNullSubclass(cls, closedWorld); 310 return new TypeMask.nonNullSubclass(cls, closedWorld);
311 } else { 311 } else {
312 // TODO(johnniwinther): Avoid the need for this case. 312 // TODO(johnniwinther): Avoid the need for this case.
313 return const TypeMask.empty(); 313 return const TypeMask.empty();
314 } 314 }
315 }), 315 }),
316 closedWorld); 316 closedWorld);
317 } 317 }
318 } 318 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/universe/element_world_builder.dart ('k') | pkg/compiler/testing_strong.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698