Isn't the problem that the compression algorithm is chosen at runtime depending on which one yields the smaller compressed data size? So at the time when compressedSize (or uncompressedSize) is called the algorithm hasn't even seen the uncompressed byte buffer and only way to know is via this gatherStatsForCompressability method.

I agree the current version seems wasteful but unless one changes the "contract" between the compression and the surrounding code I see no other solution but please correct me if I missed something.