On Friday 17 April 2009 12:48:23 j16sdiz at freenetproject.org wrote: > Author: j16sdiz > Date: 2009-04-17 11:48:22 +0000 (Fri, 17 Apr 2009) > New Revision: 26934 > > Modified: > trunk/freenet/src/freenet/client/async/InsertCompressor.java > Log: > Actually, we don't need this check > > Modified: trunk/freenet/src/freenet/client/async/InsertCompressor.java > =================================================================== > --- trunk/freenet/src/freenet/client/async/InsertCompressor.java > 2009-04-17 11:45:10 UTC (rev 26933) > +++ trunk/freenet/src/freenet/client/async/InsertCompressor.java > 2009-04-17 11:48:22 UTC (rev 26934) > @@ -133,6 +133,7 @@ > > result = comp.compress(origData, > bucketFactory2, origSize, bestCompressedDataSize); > long resultSize = result.size(); > + // minSize is > {SSKBlock,CHKBlock}.MAX_COMPRESSED_DATA_LENGTH > if(resultSize < minSize) { > if(logMINOR) > Logger.minor(this, "New size > "+resultSize+" smaller then minSize "+minSize); > @@ -146,10 +147,7 @@ > shouldFreeOnFinally = false; > break; > } > - if(resultSize < bestCompressedDataSize && > - // If compressing to CHK, > origSize will always be greater > - // If compressing to SSK, we > are not interested unless we can get it small enough to fit in the SSK itself > - (origSize > > CHKBlock.DATA_LENGTH || resultSize <= SSKBlock.DATA_LENGTH)) { > + if(resultSize < bestCompressedDataSize) { > if(logMINOR) > Logger.minor(this, "New size > "+resultSize+" better than old best "+bestCompressedDataSize); > if(bestCompressedData != null && > bestCompressedData != origData)
This is correct, but not for the reasons given. We already check whether it fits in a block of the expected size. And if it is over a block originally, clearly we want to compress it. The interesting case is when we want to insert it to an SSK (minSize = 1K), but it only fits into a CHK (32K). However, for reasons of crypto, we should always insert the best (smallest) compressed data, even if it takes the same time to transfer and longer to decompress. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 835 bytes Desc: This is a digitally signed message part. URL: <https://emu.freenetproject.org/pipermail/devl/attachments/20090418/6cc8d03f/attachment.pgp>