~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/pack.py

  • Committer: Andrew Bennetts
  • Date: 2007-10-22 04:50:17 UTC
  • mto: (2535.4.16 streaming-smart-fetch)
  • mto: This revision was merged to the branch mainline in revision 2981.
  • Revision ID: andrew.bennetts@canonical.com-20071022045017-rxuvzs4slk4pbprs
Extract a _serialise_byte_records function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
            and thus are only suitable for use by a ContainerReader.
104
104
        """
105
105
        current_offset = self.current_offset
 
106
        serialised_record = self._serialise_bytes_record(bytes, names)
 
107
        self.write_func(serialised_record)
 
108
        self.records_written += 1
 
109
        # return a memo of where we wrote data to allow random access.
 
110
        return current_offset, self.current_offset - current_offset
 
111
 
 
112
    def _serialise_bytes_record(self, bytes, names):
106
113
        # Kind marker
107
114
        byte_sections = ["B"]
108
115
        # Length
126
133
        # memory pressure in that case. One possibly improvement here is to
127
134
        # check the size of the content before deciding to join here vs call
128
135
        # write twice.
129
 
        self.write_func(''.join(byte_sections))
130
 
        self.records_written += 1
131
 
        # return a memo of where we wrote data to allow random access.
132
 
        return current_offset, self.current_offset - current_offset
 
136
        return ''.join(byte_sections)
133
137
 
134
138
 
135
139
class ReadVFile(object):