~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff-delta.c

  • Committer: Ian Clatworthy
  • Date: 2010-02-19 03:02:07 UTC
  • mto: (4797.23.1 integration-2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: ian.clatworthy@canonical.com-20100219030207-zpbzx021zavx4sqt
What's New in 2.1 - a summary of changes since 2.0

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, *old_entry;
 
691
    struct index_entry *entry, *entries;
692
692
 
693
693
    if (!src->buf || !src->size)
694
694
        return NULL;
713
713
    prev_val = ~0;
714
714
    data = buffer;
715
715
    /* target size */
716
 
    get_delta_hdr_size(&data, top);
 
716
    /* get_delta_hdr_size doesn't mutate the content, just moves the
 
717
     * start-of-data pointer, so it is safe to do the cast.
 
718
     */
 
719
    get_delta_hdr_size((unsigned char**)&data, top);
717
720
    entry = entries; /* start at the first slot */
718
721
    num_entries = 0; /* calculate the real number of entries */
719
722
    while (data < top) {
786
789
    entry = entries;
787
790
    num_inserted = 0;
788
791
    for (; num_entries > 0; --num_entries, ++entry) {
 
792
        struct index_entry *next_bucket_entry, *cur_entry, *bucket_first_entry;
789
793
        hash_offset = (entry->val & old_index->hash_mask);
790
794
        /* The basic structure is a hash => packed_entries that fit in that
791
795
         * hash bucket. Things are structured such that the hash-pointers are
794
798
         * forward. If there are no NULL targets, then we know because
795
799
         * entry->ptr will not be NULL.
796
800
         */
797
 
        old_entry = old_index->hash[hash_offset + 1];
798
 
        old_entry--;
799
 
        while (old_entry->ptr == NULL
800
 
               && old_entry >= old_index->hash[hash_offset]) {
801
 
            old_entry--;
 
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--;
802
809
        }
803
 
        old_entry++;
804
 
        if (old_entry->ptr != NULL
805
 
            || old_entry >= old_index->hash[hash_offset + 1]) {
 
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
814
            /* There is no room for this entry, we have to resize */
807
815
            // char buff[128];
808
816
            // get_text(buff, entry->ptr);
819
827
            break;
820
828
        }
821
829
        num_inserted++;
822
 
        *old_entry = *entry;
 
830
        *cur_entry = *entry;
823
831
        /* For entries which we *do* manage to insert into old_index, we don't
824
832
         * want them double copied into the final output.
825
833
         */