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

Side by Side Diff: sdk/lib/convert/line_splitter.dart

Issue 1698563002: Provide a better type for line-splitter's bind. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.convert; 5 part of dart.convert;
6 6
7 // Character constants. 7 // Character constants.
8 const int _LF = 10; 8 const int _LF = 10;
9 const int _CR = 13; 9 const int _CR = 13;
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 List<String> convert(String data) => split(data).toList(); 52 List<String> convert(String data) => split(data).toList();
53 53
54 StringConversionSink startChunkedConversion(Sink<String> sink) { 54 StringConversionSink startChunkedConversion(Sink<String> sink) {
55 if (sink is! StringConversionSink) { 55 if (sink is! StringConversionSink) {
56 sink = new StringConversionSink.from(sink); 56 sink = new StringConversionSink.from(sink);
57 } 57 }
58 return new _LineSplitterSink(sink); 58 return new _LineSplitterSink(sink);
59 } 59 }
60
61 Stream<String> bind(Stream<String> stream) => super.bind(stream);
60 } 62 }
61 63
62 // TODO(floitsch): deal with utf8. 64 // TODO(floitsch): deal with utf8.
63 class _LineSplitterSink extends StringConversionSinkBase { 65 class _LineSplitterSink extends StringConversionSinkBase {
64 final StringConversionSink _sink; 66 final StringConversionSink _sink;
65 67
66 /// The carry-over from the previous chunk. 68 /// The carry-over from the previous chunk.
67 /// 69 ///
68 /// If the previous slice ended in a line without a line terminator, 70 /// If the previous slice ended in a line without a line terminator,
69 /// then the next slice may continue the line. 71 /// then the next slice may continue the line.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 _sink.add(lines.substring(sliceStart, i)); 129 _sink.add(lines.substring(sliceStart, i));
128 sliceStart = i + 1; 130 sliceStart = i + 1;
129 } 131 }
130 if (sliceStart < end) { 132 if (sliceStart < end) {
131 _carry = lines.substring(sliceStart, end); 133 _carry = lines.substring(sliceStart, end);
132 } else { 134 } else {
133 _skipLeadingLF = (char == _CR); 135 _skipLeadingLF = (char == _CR);
134 } 136 }
135 } 137 }
136 } 138 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698