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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/universe/function_set.dart

Issue 12262035: Simplify the selector map and get rid of the partial type tree. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: iterateMatching -> computeMatching. Created 7 years, 10 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 universe; 5 part of universe;
6 6
7 // TODO(kasperl): This actually holds getters and setters just fine 7 // TODO(kasperl): This actually holds getters and setters just fine
8 // too and stricly they aren't functions. Maybe this needs a better 8 // too and stricly they aren't functions. Maybe this needs a better
9 // name -- something like ElementSet seems a bit too generic. 9 // name -- something like ElementSet seems a bit too generic.
10 class FunctionSet { 10 class FunctionSet {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 assert(element.name == name); 82 assert(element.name == name);
83 // We try to avoid clearing the cache unless we have to. For that 83 // We try to avoid clearing the cache unless we have to. For that
84 // reason we keep the explicit contains check even though the add 84 // reason we keep the explicit contains check even though the add
85 // method ends up doing the work again (for sets). 85 // method ends up doing the work again (for sets).
86 if (!elements.contains(element)) { 86 if (!elements.contains(element)) {
87 if (isList && elements.length >= MAX_ELEMENTS_IN_LIST) { 87 if (isList && elements.length >= MAX_ELEMENTS_IN_LIST) {
88 elements = elements.toSet(); 88 elements = elements.toSet();
89 isList = false; 89 isList = false;
90 } 90 }
91 elements.add(element); 91 elements.add(element);
92 cache.clear(); 92 if (!cache.isEmpty) cache.clear();
ngeoffray 2013/02/14 10:14:33 Why adding this?
93 } 93 }
94 } 94 }
95 95
96 void remove(Element element) { 96 void remove(Element element) {
97 assert(element.name == name); 97 assert(element.name == name);
98 if (isList) { 98 if (isList) {
99 List list = elements; 99 List list = elements;
100 int index = list.indexOf(element); 100 int index = list.indexOf(element);
101 if (index < 0) return; 101 if (index < 0) return;
102 Element last = list.removeLast(); 102 Element last = list.removeLast();
103 if (index != list.length) { 103 if (index != list.length) {
104 list[index] = last; 104 list[index] = last;
105 } 105 }
106 cache.clear(); 106 if (!cache.isEmpty) cache.clear();
107 } else { 107 } else {
108 Set set = elements; 108 Set set = elements;
109 if (set.remove(element)) { 109 if (set.remove(element)) {
110 // To avoid wobbling between the two representations, we do 110 // To avoid wobbling between the two representations, we do
111 // not transition back to the list representation even if we 111 // not transition back to the list representation even if we
112 // end up with few enough elements at this point. 112 // end up with few enough elements at this point.
113 cache.clear(); 113 if (!cache.isEmpty) cache.clear();
114 } 114 }
115 } 115 }
116 } 116 }
117 117
118 bool contains(Element element) { 118 bool contains(Element element) {
119 assert(element.name == name); 119 assert(element.name == name);
120 return elements.contains(element); 120 return elements.contains(element);
121 } 121 }
122 122
123 void forEach(Function action) { 123 void forEach(Function action) {
(...skipping 13 matching lines...) Expand all
137 result = <Element>[]; 137 result = <Element>[];
138 } 138 }
139 result.add(element); 139 result.add(element);
140 } 140 }
141 } 141 }
142 if (result == null) result = const <Element>[]; 142 if (result == null) result = const <Element>[];
143 cache[selector] = result; 143 cache[selector] = result;
144 return result; 144 return result;
145 } 145 }
146 } 146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698