/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/diff-delta.c

  • Committer: John Arbash Meinel
  • Date: 2009-11-06 18:05:03 UTC
  • mto: This revision was merged to the branch mainline in revision 4814.
  • Revision ID: john@arbash-meinel.com-20091106180503-q3hcg1nxmut5b2cb
Stop holding the gil while extracting data.

Previous experience has shown that we don't really spend a lot
of time here, but there isn't any reason to hold the lock while
we do it anyway.

Performance testing has shown that for bzr operations 'with nogil'
doesn't really do much, which was generally expected. Any variation
observed is within the noise margins.

This is mostly about 'the right thing to do', and potential
future work where we may actually use threads.

Show diffs side-by-side

added added

removed removed

Lines of Context:
688
688
    const unsigned char *data, *buffer, *top;
689
689
    unsigned char cmd;
690
690
    struct delta_index *new_index;
691
 
    struct index_entry *entry, *entries;
 
691
    struct index_entry *entry, *entries, *old_entry;
692
692
 
693
693
    if (!src->buf || !src->size)
694
694
        return NULL;
789
789
    entry = entries;
790
790
    num_inserted = 0;
791
791
    for (; num_entries > 0; --num_entries, ++entry) {
792
 
        struct index_entry *next_bucket_entry, *cur_entry, *bucket_first_entry;
793
792
        hash_offset = (entry->val & old_index->hash_mask);
794
793
        /* The basic structure is a hash => packed_entries that fit in that
795
794
         * hash bucket. Things are structured such that the hash-pointers are
798
797
         * forward. If there are no NULL targets, then we know because
799
798
         * entry->ptr will not be NULL.
800
799
         */
801
 
        // The start of the next bucket, this may point past the end of the
802
 
        // entry table if hash_offset is the last bucket.
803
 
        next_bucket_entry = old_index->hash[hash_offset + 1];
804
 
        // First entry in this bucket
805
 
        bucket_first_entry = old_index->hash[hash_offset];
806
 
        cur_entry = next_bucket_entry - 1;
807
 
        while (cur_entry->ptr == NULL && cur_entry >= bucket_first_entry) {
808
 
            cur_entry--;
 
800
        old_entry = old_index->hash[hash_offset + 1];
 
801
        old_entry--;
 
802
        while (old_entry->ptr == NULL
 
803
               && old_entry >= old_index->hash[hash_offset]) {
 
804
            old_entry--;
809
805
        }
810
 
        // cur_entry now either points at the first NULL, or it points to
811
 
        // next_bucket_entry if there were no blank spots.
812
 
        cur_entry++;
813
 
        if (cur_entry >= next_bucket_entry || cur_entry->ptr != NULL) {
 
806
        old_entry++;
 
807
        if (old_entry->ptr != NULL
 
808
            || old_entry >= old_index->hash[hash_offset + 1]) {
814
809
            /* There is no room for this entry, we have to resize */
815
810
            // char buff[128];
816
811
            // get_text(buff, entry->ptr);
827
822
            break;
828
823
        }
829
824
        num_inserted++;
830
 
        *cur_entry = *entry;
 
825
        *old_entry = *entry;
831
826
        /* For entries which we *do* manage to insert into old_index, we don't
832
827
         * want them double copied into the final output.
833
828
         */