~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_annotator_py.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-18 02:20:00 UTC
  • mto: This revision was merged to the branch mainline in revision 4522.
  • Revision ID: john@arbash-meinel.com-20090618022000-papy89z58jkbhmj8
Adding a trivial 'last_entry' cache drops the time from 56s down to 40s
This finally becomes approximately as fast as plain annotation w/ heads.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        parent_annotations, matching_blocks = self._get_parent_annotations_and_matches(
78
78
            lines, parent_key)
79
79
 
 
80
        last_ann = None
 
81
        last_parent = None
 
82
        last_res = None
80
83
        simple_key_ann = (key,)
81
84
        for parent_idx, lines_idx, match_len in matching_blocks:
82
85
            # For lines which match this parent, we will now resolve whether
95
98
                    continue
96
99
                # Now we have a conflict, both sides claim to have introduced
97
100
                # this line
98
 
                new_ann = set(ann)
99
 
                assert key not in new_ann
100
 
                # new_ann.discard(key)
101
 
                new_ann.update(par_ann)
102
 
                new_ann = tuple(sorted(new_ann))
103
 
                annotations[ann_idx] = new_ann
 
101
                if ann == last_ann and par_ann == last_parent:
 
102
                    annotations[ann_idx] = last_res
 
103
                else:
 
104
                    new_ann = set(ann)
 
105
                    assert key not in new_ann
 
106
                    # new_ann.discard(key)
 
107
                    new_ann.update(par_ann)
 
108
                    new_ann = tuple(sorted(new_ann))
 
109
                    annotations[ann_idx] = new_ann
 
110
                    last_ann = ann
 
111
                    last_parent = par_ann
 
112
                    last_res = new_ann
104
113
 
105
114
    def annotate(self, key):
106
115
        """Return annotated fulltext for the given key."""