| 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 import "dart:collection" show LinkedList, LinkedListEntry; | 5 import "dart:collection" show LinkedList, LinkedListEntry; |
| 6 | 6 |
| 7 patch class RegExp { | 7 patch class RegExp { |
| 8 /* patch */ factory RegExp(String source, | 8 /* patch */ factory RegExp(String source, |
| 9 {bool multiLine: false, | 9 {bool multiLine: false, |
| 10 bool caseSensitive: true}) { | 10 bool caseSensitive: true}) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // Regular expression objects are stored in a cache of up to _MAX_CACHE_SIZE | 41 // Regular expression objects are stored in a cache of up to _MAX_CACHE_SIZE |
| 42 // elements using an LRU eviction strategy. | 42 // elements using an LRU eviction strategy. |
| 43 // TODO(zerny): Do not impose a fixed limit on the number of cached objects. | 43 // TODO(zerny): Do not impose a fixed limit on the number of cached objects. |
| 44 // Other possibilities could be limiting by the size of the regexp objects, | 44 // Other possibilities could be limiting by the size of the regexp objects, |
| 45 // or imposing a lower time bound for the most recent use under which a regexp | 45 // or imposing a lower time bound for the most recent use under which a regexp |
| 46 // may not be removed from the cache. | 46 // may not be removed from the cache. |
| 47 // TODO(zerny): Use self-sizing cache similar to _AccessorCache in | 47 // TODO(zerny): Use self-sizing cache similar to _AccessorCache in |
| 48 // mirrors_impl.dart. | 48 // mirrors_impl.dart. |
| 49 static const int _MAX_CACHE_SIZE = 256; | 49 static const int _MAX_CACHE_SIZE = 256; |
| 50 static final Map<_JSSyntaxRegExpHashKey, _JSSyntaxRegExp> _cache = | 50 static final Map<_JSSyntaxRegExpHashKey, _JSSyntaxRegExp> _cache = |
| 51 new HashMap<_JSSyntaxRegExpHashKey, _JSSyntaxRegExpValue>(); | 51 new HashMap<_JSSyntaxRegExpHashKey, _JSSyntaxRegExpHashValue>(); |
| 52 static final LinkedList<_JSSyntaxRegExpHashKey> _recentlyUsed = | 52 static final LinkedList<_JSSyntaxRegExpHashKey> _recentlyUsed = |
| 53 new LinkedList<_JSSyntaxRegExpHashKey>(); | 53 new LinkedList<_JSSyntaxRegExpHashKey>(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 // Represents both a key in the regular expression cache as well as its | 57 // Represents both a key in the regular expression cache as well as its |
| 58 // corresponding entry in the LRU list. | 58 // corresponding entry in the LRU list. |
| 59 class _JSSyntaxRegExpHashKey extends LinkedListEntry<_JSSyntaxRegExpHashKey> { | 59 class _JSSyntaxRegExpHashKey extends LinkedListEntry<_JSSyntaxRegExpHashKey> { |
| 60 final String pattern; | 60 final String pattern; |
| 61 final bool multiLine; | 61 final bool multiLine; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 _nextIndex++; | 274 _nextIndex++; |
| 275 } | 275 } |
| 276 return true; | 276 return true; |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 _current = null; | 279 _current = null; |
| 280 _re = null; | 280 _re = null; |
| 281 return false; | 281 return false; |
| 282 } | 282 } |
| 283 } | 283 } |
| OLD | NEW |