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

Side by Side Diff: sdk/lib/collection/collections.dart

Issue 12310103: Small cleanups in RegExp to avoid generating lots of code just because there is a try/catch in our … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/tracer.dart ('k') | sdk/lib/core/regexp.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dart.collection; 5 part of dart.collection;
6 6
7 /** 7 /**
8 * This class provides default implementations for Iterables (including Lists). 8 * This class provides default implementations for Iterables (including Lists).
9 * 9 *
10 * Once Dart receives Mixins it will be replaced with mixin classes. 10 * Once Dart receives Mixins it will be replaced with mixin classes.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 for (var element in collection) { 108 for (var element in collection) {
109 if (test(element)) elementsToRemove.add(element); 109 if (test(element)) elementsToRemove.add(element);
110 } 110 }
111 collection.removeAll(elementsToRemove); 111 collection.removeAll(elementsToRemove);
112 } 112 }
113 113
114 /** 114 /**
115 * Removes elements matching [test] from [list]. 115 * Removes elements matching [test] from [list].
116 * 116 *
117 * This is performed in two steps, to avoid exposing an inconsistent state 117 * This is performed in two steps, to avoid exposing an inconsistent state
118 * to the [test] function. First the elements to ratain are found, and then 118 * to the [test] function. First the elements to retain are found, and then
119 * the original list is updated to contain those elements. 119 * the original list is updated to contain those elements.
120 */ 120 */
121 static void removeMatchingList(List list, bool test(var element)) { 121 static void removeMatchingList(List list, bool test(var element)) {
122 List retained = []; 122 List retained = [];
123 int length = list.length; 123 int length = list.length;
124 for (int i = 0; i < length; i++) { 124 for (int i = 0; i < length; i++) {
125 var element = list[i]; 125 var element = list[i];
126 if (!test(element)) { 126 if (!test(element)) {
127 retained.add(element); 127 retained.add(element);
128 } 128 }
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 * The source of the elements may be a [List] or any [Iterable] with 368 * The source of the elements may be a [List] or any [Iterable] with
369 * efficient [Iterable.length] and [Iterable.elementAt]. 369 * efficient [Iterable.length] and [Iterable.elementAt].
370 */ 370 */
371 class UnmodifiableListView<E> extends UnmodifiableListBase<E> { 371 class UnmodifiableListView<E> extends UnmodifiableListBase<E> {
372 Iterable<E> _source; 372 Iterable<E> _source;
373 /** Create an unmodifiable list backed by [source]. */ 373 /** Create an unmodifiable list backed by [source]. */
374 UnmodifiableListView(Iterable<E> source) : _source = source; 374 UnmodifiableListView(Iterable<E> source) : _source = source;
375 int get length => _source.length; 375 int get length => _source.length;
376 E operator[](int index) => _source.elementAt(index); 376 E operator[](int index) => _source.elementAt(index);
377 } 377 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/tracer.dart ('k') | sdk/lib/core/regexp.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698