Skip to content

Commit

Permalink
Fix analyzer issues in bsdiff (flutter#342)
Browse files Browse the repository at this point in the history
Fixes minor issues flagged by the analyzer in preparation for fixing the
CI to run checks against the packages in third_party/packages.
  • Loading branch information
stuartmorgan authored May 5, 2021
1 parent 7d8f156 commit 75a2100
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions third_party/packages/bsdiff/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: main
description: A simple example of how to use bsdiff to generate and apply patches.
version: 0.1.0
publish_to: none

dependencies:
bsdiff:
Expand Down
10 changes: 6 additions & 4 deletions third_party/packages/bsdiff/lib/bsdiff.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void _split(List<int> idata, List<int> vdata, int start, int len, int h) {

void _qsufsort(List<int> idata, List<int> vdata, Uint8List olddata) {
final int oldsize = olddata.length;
final List<int> buckets = List<int>(256);
final List<int> buckets = <int>[256];

for (int i = 0; i < 256; i++) {
buckets[i] = 0;
Expand Down Expand Up @@ -207,12 +207,13 @@ int _search(List<int> idata, Uint8List olddata, Uint8List newdata, int newskip,
List<int> _int64bytes(int i) =>
(ByteData(8)..setInt64(0, i)).buffer.asUint8List();

/// Computes the binary diff between [olddata] and [newdata].
Uint8List bsdiff(List<int> olddata, List<int> newdata) {
final int oldsize = olddata.length;
final int newsize = newdata.length;

final List<int> idata = List<int>(oldsize + 1);
_qsufsort(idata, List<int>(oldsize + 1), olddata);
final List<int> idata = <int>[oldsize + 1];
_qsufsort(idata, <int>[oldsize + 1], olddata);

final Uint8List db = Uint8List(newsize + 1);
final Uint8List eb = Uint8List(newsize + 1);
Expand Down Expand Up @@ -346,6 +347,7 @@ Uint8List bsdiff(List<int> olddata, List<int> newdata) {
return bytes;
}

/// Returns the result of applying [diffdata] to [olddata].
Uint8List bspatch(List<int> olddata, List<int> diffdata) {
final List<int> magic = diffdata.sublist(0, 8);
if (const AsciiCodec().decode(magic) != 'BZDIFF40') {
Expand Down Expand Up @@ -377,7 +379,7 @@ Uint8List bspatch(List<int> olddata, List<int> diffdata) {
int newpos = 0;

while (newpos < newsize) {
final List<int> ctrl = List<int>(3);
final List<int> ctrl = <int>[3];
for (int i = 0; i <= 2; i++) {
ctrl[i] = cpfdata.getInt64(8 * cpfpos++);
}
Expand Down

0 comments on commit 75a2100

Please sign in to comment.