| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library analyzer.src.summary.api_signature; | 5 library analyzer.src.summary.api_signature; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'dart:typed_data'; | 8 import 'dart:typed_data'; |
| 9 | 9 |
| 10 import 'package:convert/convert.dart'; | 10 import 'package:convert/convert.dart'; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 _data.setUint8(_offset, b ? 1 : 0); | 65 _data.setUint8(_offset, b ? 1 : 0); |
| 66 _offset++; | 66 _offset++; |
| 67 } | 67 } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Collect a sequence of arbitrary bytes. Note that the length is not | 70 * Collect a sequence of arbitrary bytes. Note that the length is not |
| 71 * collected, so for example `addBytes([1, 2]);` will have the same effect as | 71 * collected, so for example `addBytes([1, 2]);` will have the same effect as |
| 72 * `addBytes([1]); addBytes([2]);`. | 72 * `addBytes([1]); addBytes([2]);`. |
| 73 */ | 73 */ |
| 74 void addBytes(List<int> bytes) { | 74 void addBytes(List<int> bytes) { |
| 75 _makeRoom(bytes.length); | 75 int length = bytes.length; |
| 76 new Uint8List.view(_data.buffer) | 76 _makeRoom(length); |
| 77 .setRange(_offset, _offset + bytes.length, bytes); | 77 for (int i = 0; i < length; i++) { |
| 78 _offset += bytes.length; | 78 _data.setUint8(_offset + i, bytes[i]); |
| 79 } |
| 80 _offset += length; |
| 79 } | 81 } |
| 80 | 82 |
| 81 /** | 83 /** |
| 82 * Collect a double-precision floating point value. | 84 * Collect a double-precision floating point value. |
| 83 */ | 85 */ |
| 84 void addDouble(double d) { | 86 void addDouble(double d) { |
| 85 _makeRoom(8); | 87 _makeRoom(8); |
| 86 _data.setFloat64(_offset, d, Endianness.LITTLE_ENDIAN); | 88 _data.setFloat64(_offset, d, Endianness.LITTLE_ENDIAN); |
| 87 _offset += 8; | 89 _offset += 8; |
| 88 } | 90 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 int oldLength = _data.lengthInBytes; | 144 int oldLength = _data.lengthInBytes; |
| 143 if (_offset + spaceNeeded > oldLength) { | 145 if (_offset + spaceNeeded > oldLength) { |
| 144 int newLength = 2 * (_offset + spaceNeeded); | 146 int newLength = 2 * (_offset + spaceNeeded); |
| 145 ByteData newData = new ByteData(newLength); | 147 ByteData newData = new ByteData(newLength); |
| 146 new Uint8List.view(newData.buffer) | 148 new Uint8List.view(newData.buffer) |
| 147 .setRange(0, oldLength, new Uint8List.view(_data.buffer)); | 149 .setRange(0, oldLength, new Uint8List.view(_data.buffer)); |
| 148 _data = newData; | 150 _data = newData; |
| 149 } | 151 } |
| 150 } | 152 } |
| 151 } | 153 } |
| OLD | NEW |