~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-05 19:57:15 UTC
  • mto: (4413.5.2 1.16-chk-direct)
  • mto: This revision was merged to the branch mainline in revision 4442.
  • Revision ID: john@arbash-meinel.com-20090605195715-q2gcpaypbixwk4wg
Move the boolean check to the first part of the if statement

Show diffs side-by-side

added added

removed removed

Lines of Context:
324
324
                raise ValueError('invalid content_len %d for record @ pos %d'
325
325
                                 % (content_len, pos - len_len - 1))
326
326
            if kind == 'f': # Fulltext
327
 
                result.append(('f', content_len))
 
327
                if include_text:
 
328
                    text = self._content[pos:pos+content_len]
 
329
                    result.append(('f', content_len, text))
 
330
                else:
 
331
                    result.append(('f', content_len))
328
332
            elif kind == 'd': # Delta
329
333
                delta_content = self._content[pos:pos+content_len]
330
334
                delta_info = []
339
343
                        (offset, length,
340
344
                         delta_pos) = decode_copy_instruction(delta_content, c,
341
345
                                                              delta_pos)
342
 
                        delta_info.append(('c', offset, length))
 
346
                        if include_text:
 
347
                            text = self._content[offset:offset+length]
 
348
                            delta_info.append(('c', offset, length, text))
 
349
                        else:
 
350
                            delta_info.append(('c', offset, length))
343
351
                        measured_len += length
344
352
                    else: # Insert
345
353
                        if include_text:
746
754
 
747
755
        After calling this, the compressor should no longer be used
748
756
        """
 
757
        # TODO: this causes us to 'bloat' to 2x the size of content in the
 
758
        #       group. This has an impact for 'commit' of large objects.
 
759
        #       One possibility is to use self._content_chunks, and be lazy and
 
760
        #       only fill out self._content as a full string when we actually
 
761
        #       need it. That would at least drop the peak memory consumption
 
762
        #       for 'commit' down to ~1x the size of the largest file, at a
 
763
        #       cost of increased complexity within this code. 2x is still <<
 
764
        #       3x the size of the largest file, so we are doing ok.
749
765
        content = ''.join(self.chunks)
750
766
        self.chunks = None
751
767
        self._delta_index = None