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

Side by Side Diff: sdk/lib/async/stream_pipe.dart

Issue 2475303002: Revert "Handle the case of Stream.take(0) better." This reverts commit 8cead4090cc0b1184a2ad552003a… (Closed)
Patch Set: Created 4 years, 1 month 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 | « sdk/lib/async/stream.dart ('k') | tests/co19/co19-co19.status » ('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.async; 5 part of dart.async;
6 6
7 /** Runs user code and takes actions depending on success or failure. */ 7 /** Runs user code and takes actions depending on success or failure. */
8 _runUserCode(userCode(), 8 _runUserCode(userCode(),
9 onSuccess(value), 9 onSuccess(value),
10 onError(error, StackTrace stackTrace)) { 10 onError(error, StackTrace stackTrace)) {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // This test is done early to avoid handling an async error 319 // This test is done early to avoid handling an async error
320 // in the _handleData method. 320 // in the _handleData method.
321 if (count is! int) throw new ArgumentError(count); 321 if (count is! int) throw new ArgumentError(count);
322 } 322 }
323 323
324 StreamSubscription<T> _createSubscription( 324 StreamSubscription<T> _createSubscription(
325 void onData(T data), 325 void onData(T data),
326 Function onError, 326 Function onError,
327 void onDone(), 327 void onDone(),
328 bool cancelOnError) { 328 bool cancelOnError) {
329 if (_count == 0) {
330 return new _DoneStreamSubscription<T>(onDone);
331 }
332 return new _StateStreamSubscription<T>( 329 return new _StateStreamSubscription<T>(
333 this, onData, onError, onDone, cancelOnError, _count); 330 this, onData, onError, onDone, cancelOnError, _count);
334 } 331 }
335 332
336 void _handleData(T inputEvent, _EventSink<T> sink) { 333 void _handleData(T inputEvent, _EventSink<T> sink) {
337 _StateStreamSubscription<T> subscription = sink; 334 _StateStreamSubscription<T> subscription = sink;
338 int count = subscription._count; 335 int count = subscription._count;
339 if (count > 0) { 336 if (count > 0) {
340 sink._add(inputEvent); 337 sink._add(inputEvent);
341 count -= 1; 338 count -= 1;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 _addErrorWithReplacement(sink, e, s); 486 _addErrorWithReplacement(sink, e, s);
490 return null; 487 return null;
491 } 488 }
492 if (!isEqual) { 489 if (!isEqual) {
493 sink._add(inputEvent); 490 sink._add(inputEvent);
494 _previous = inputEvent; 491 _previous = inputEvent;
495 } 492 }
496 } 493 }
497 } 494 }
498 } 495 }
OLDNEW
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | tests/co19/co19-co19.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698