~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revfile.py

  • Committer: mbp at sourcefrog
  • Date: 2005-04-09 05:09:10 UTC
  • Revision ID: mbp@sourcefrog.net-20050409050910-e7b81c0a5307a9b50ca9997b
show compression ratio

Show diffs side-by-side

added added

removed removed

Lines of Context:
178
178
        This does the compression if that makes sense."""
179
179
 
180
180
        flags = 0
181
 
        if len(data) > 50:
 
181
        data_len = len(data)
 
182
        if data_len > 50:
182
183
            # don't do compression if it's too small; it's unlikely to win
183
184
            # enough to be worthwhile
184
185
            compr_data = zlib.compress(data)
185
 
            if len(compr_data) < len(data):
 
186
            compr_len = len(compr_data)
 
187
            if compr_len < data_len:
186
188
                data = compr_data
187
189
                flags = FL_GZIP
 
190
                print '- compressed %d -> %d, %.1f%%' \
 
191
                      % (data_len, compr_len, float(compr_len)/float(data_len) * 100.0)
188
192
        
189
193
        idx = len(self)
190
194
        self.datafile.seek(0, 2)        # to end