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

Side by Side Diff: test/dart_codegen/expect/convert/line_splitter.dart

Issue 963593002: Disable formatting and add new-lines to make tests faster. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 part of dart.convert; 1 part of dart.convert;
2 2 class LineSplitter extends Converter<String, List<String>> {const LineSplitter( );
3 class LineSplitter extends Converter<String, List<String>> { 3 List<String> convert(String data) {
4 const LineSplitter(); 4 var lines = new List<String>();
5 List<String> convert(String data) { 5 _LineSplitterSink._addSlice(data, 0, data.length, true, lines.add);
6 var lines = new List<String>(); 6 return lines;
7 _LineSplitterSink._addSlice(data, 0, data.length, true, lines.add);
8 return lines;
9 } 7 }
10 StringConversionSink startChunkedConversion(Sink<String> sink) { 8 StringConversionSink startChunkedConversion(Sink<String> sink) {
11 if (sink is! StringConversionSink) { 9 if (sink is! StringConversionSink) {
12 sink = new StringConversionSink.from(sink); 10 sink = new StringConversionSink.from(sink);
13 } 11 }
14 return new _LineSplitterSink(sink); 12 return new _LineSplitterSink(sink);
15 } 13 }
16 } 14 }
17 class _LineSplitterSink extends StringConversionSinkBase { 15 class _LineSplitterSink extends StringConversionSinkBase {static const int _LF = 10;
18 static const int _LF = 10; 16 static const int _CR = 13;
19 static const int _CR = 13; 17 final StringConversionSink _sink;
20 final StringConversionSink _sink; 18 String _carry;
21 String _carry; 19 _LineSplitterSink(this._sink);
22 _LineSplitterSink(this._sink); 20 void addSlice(String chunk, int start, int end, bool isLast) {
23 void addSlice(String chunk, int start, int end, bool isLast) { 21 if (_carry != null) {
24 if (_carry != null) { 22 chunk = _carry + chunk.substring(start, end);
25 chunk = _carry + chunk.substring(start, end); 23 start = 0;
26 start = 0; 24 end = chunk.length;
27 end = chunk.length; 25 _carry = null;
28 _carry = null; 26 }
27 _carry = _addSlice(chunk, start, end, isLast, _sink.add);
28 if (isLast) _sink.close();
29 }
30 void close() {
31 addSlice('', 0, 0, true);
32 }
33 static String _addSlice(String chunk, int start, int end, bool isLast, void add er(String val)) {
34 int pos = start;
35 while (pos < end) {
36 int skip = 0;
37 int char = chunk.codeUnitAt(pos);
38 if (char == _LF) {
39 skip = 1;
29 } 40 }
30 _carry = _addSlice(chunk, start, end, isLast, _sink.add); 41 else if (char == _CR) {
31 if (isLast) _sink.close(); 42 skip = 1;
32 } 43 if (pos + 1 < end) {
33 void close() { 44 if (chunk.codeUnitAt(pos + 1) == _LF) {
34 addSlice('', 0, 0, true); 45 skip = 2;
35 }
36 static String _addSlice(
37 String chunk, int start, int end, bool isLast, void adder(String val)) {
38 int pos = start;
39 while (pos < end) {
40 int skip = 0;
41 int char = chunk.codeUnitAt(pos);
42 if (char == _LF) {
43 skip = 1;
44 } else if (char == _CR) {
45 skip = 1;
46 if (pos + 1 < end) {
47 if (chunk.codeUnitAt(pos + 1) == _LF) {
48 skip = 2;
49 }
50 } else if (!isLast) {
51 return chunk.substring(start, end);
52 } 46 }
53 } 47 }
54 if (skip > 0) { 48 else if (!isLast) {
55 adder(chunk.substring(start, pos)); 49 return chunk.substring(start, end);
56 start = pos = pos + skip;
57 } else {
58 pos++;
59 } 50 }
60 } 51 }
61 if (pos != start) { 52 if (skip > 0) {
62 var carry = chunk.substring(start, pos); 53 adder(chunk.substring(start, pos));
63 if (isLast) { 54 start = pos = pos + skip;
64 adder(carry);
65 } else {
66 return carry;
67 }
68 } 55 }
69 return null; 56 else {
57 pos++;
58 }
70 } 59 }
60 if (pos != start) {
61 var carry = chunk.substring(start, pos);
62 if (isLast) {
63 adder(carry);
64 }
65 else {
66 return carry;
67 }
68 }
69 return null;
71 } 70 }
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698