| OLD | NEW |
| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 class FunctionSetNode { | 67 class FunctionSetNode { |
| 68 final SourceString name; | 68 final SourceString name; |
| 69 final Map<Selector, FunctionSetQuery> cache = | 69 final Map<Selector, FunctionSetQuery> cache = |
| 70 new Map<Selector, FunctionSetQuery>(); | 70 new Map<Selector, FunctionSetQuery>(); |
| 71 | 71 |
| 72 // Initially, we keep the elements in a list because it is more | 72 // Initially, we keep the elements in a list because it is more |
| 73 // compact than a hash set. Once we get enough elements, we change | 73 // compact than a hash set. Once we get enough elements, we change |
| 74 // the representation to be a set to get faster contains checks. | 74 // the representation to be a set to get faster contains checks. |
| 75 static const int MAX_ELEMENTS_IN_LIST = 8; | 75 static const int MAX_ELEMENTS_IN_LIST = 8; |
| 76 Collection<Element> elements = <Element>[]; | 76 var elements = <Element>[]; |
| 77 bool isList = true; | 77 bool isList = true; |
| 78 | 78 |
| 79 FunctionSetNode(this.name); | 79 FunctionSetNode(this.name); |
| 80 | 80 |
| 81 void add(Element element) { | 81 void add(Element element) { |
| 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)) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 Selector selector, | 150 Selector selector, |
| 151 Compiler compiler) { | 151 Compiler compiler) { |
| 152 return new FunctionSetQuery(functions); | 152 return new FunctionSetQuery(functions); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 class FunctionSetQuery { | 156 class FunctionSetQuery { |
| 157 final List<Element> functions; | 157 final List<Element> functions; |
| 158 const FunctionSetQuery(this.functions); | 158 const FunctionSetQuery(this.functions); |
| 159 } | 159 } |
| OLD | NEW |