Skip to content

Commit

Permalink
mkasset: fix a bug in inplace margin calculation in Shrinkler
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Dec 6, 2023
1 parent 9b980cb commit 0ea5e4d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tools/common/shrinkler/Verifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class LZVerifier : public LZReceiver, public CompressedDataReadListener {
return false;
}
pos += 1;
updateMargin();
return true;
}

Expand All @@ -69,6 +70,7 @@ class LZVerifier : public LZReceiver, public CompressedDataReadListener {
}
}
pos += length;
updateMargin();
return true;
}

Expand All @@ -79,11 +81,17 @@ class LZVerifier : public LZReceiver, public CompressedDataReadListener {
void read(int index) {
// Another byte of compresed data read
if ((index & (read_size - 1)) == 0) {
int margin = pos - compressed_read_count * read_size;
if (margin > front_overlap_margin) {
front_overlap_margin = margin;
}
compressed_read_count += 1;
compressed_read_count += read_size;
if (compressed_read_count > data_length)
compressed_read_count = data_length;
updateMargin();
}
}

void updateMargin(void) {
int margin = pos - compressed_read_count;
if (margin > front_overlap_margin) {
front_overlap_margin = margin;
}
}
};

0 comments on commit 0ea5e4d

Please sign in to comment.