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

Side by Side Diff: pkg/analysis_server/lib/src/collections.dart

Issue 2933753002: Run the sorter to reduce code churn (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/constants.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /** 5 /**
6 * Returns the concatenation of the input [iterables]. 6 * Returns the concatenation of the input [iterables].
7 * 7 *
8 * The returned iterable is a lazily-evaluated view on the input iterables. 8 * The returned iterable is a lazily-evaluated view on the input iterables.
9 */ 9 */
10 Iterable/*<E>*/ concat/*<E>*/(Iterable<Iterable/*<E>*/ > iterables) => 10 Iterable/*<E>*/ concat/*<E>*/(Iterable<Iterable/*<E>*/ > iterables) =>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 * It will never grow larger than [capacity]. It's a LIFO queue - the last item 52 * It will never grow larger than [capacity]. It's a LIFO queue - the last item
53 * added will be the first one returned from [items]. 53 * added will be the first one returned from [items].
54 */ 54 */
55 class RecentBuffer<T> { 55 class RecentBuffer<T> {
56 final int capacity; 56 final int capacity;
57 57
58 List<T> _buffer = []; 58 List<T> _buffer = [];
59 59
60 RecentBuffer(this.capacity); 60 RecentBuffer(this.capacity);
61 61
62 Iterable<T> get items => _buffer.reversed;
63
62 void add(T item) { 64 void add(T item) {
63 _buffer.add(item); 65 _buffer.add(item);
64 66
65 if (_buffer.length > capacity) { 67 if (_buffer.length > capacity) {
66 _buffer.removeAt(0); 68 _buffer.removeAt(0);
67 } 69 }
68 } 70 }
69
70 Iterable<T> get items => _buffer.reversed;
71 } 71 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698