~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to groupcompress.py

More C tweaks from John.

Show diffs side-by-side

added added

removed removed

Lines of Context:
134
134
            of the list is always (old_len, new_len, 0) to provide a end point
135
135
            for generating instructions from the matching blocks list.
136
136
        """
137
 
        import time
138
137
        result = []
139
138
        pos = 0
140
139
        line_locations = self.line_locations
143
142
        # insert new lines. To find reusable lines we traverse 
144
143
        locations = None
145
144
        max_pos = len(lines)
146
 
        timer = time.clock
147
145
        max_time = 0.0
148
146
        max_info = None
 
147
        result_append = result.append
149
148
        while pos < max_pos:
150
 
            tstart = timer()
151
 
            block, next_pos, locations = _get_longest_match(line_locations, pos,
152
 
                                                            max_pos, locations)
153
 
            tdelta = timer() - tstart
154
 
            if tdelta > max_time:
155
 
                max_time = tdelta
156
 
                max_info = tdelta, pos, block, next_pos, locations
157
 
            pos = next_pos
158
 
            
 
149
            block, pos, locations = _get_longest_match(line_locations, pos,
 
150
                                                       max_pos, locations)
159
151
            if block is not None:
160
 
                result.append(block)
161
 
        result.append((len(self.lines), len(lines), 0))
162
 
        # if max_time > 0.01:
163
 
        #     print max_info[:-1]
164
 
        #     import pdb; pdb.set_trace()
 
152
                result_append(block)
 
153
        result_append((len(self.lines), len(lines), 0))
165
154
        return result
166
155
 
167
156
    def compress(self, key, lines, expected_sha):