equal value without being equal pointers, substitute one of the
pointers for the other in the file list. This optimizes future name
comparisons. Note also that this optimization won't be triggered
very often (because rsync tends to send the names grouped by dir-
name at transmission time), but it's nice to be able to assume that
all files in the same dir have identical dir-name pointers after the
qsort is finished.
static char empty_sum[MD4_SUM_LENGTH];
static unsigned int file_struct_len;
static char empty_sum[MD4_SUM_LENGTH];
static unsigned int file_struct_len;
-static struct file_list *received_flist;
+static struct file_list *received_flist, *sorting_flist;
static dev_t filesystem_dev; /* used to implement -x */
static int deletion_count = 0; /* used to implement --max-delete */
static dev_t filesystem_dev; /* used to implement -x */
static int deletion_count = 0; /* used to implement --max-delete */
if (!flist || flist->count == 0)
return;
if (!flist || flist->count == 0)
return;
qsort(flist->files, flist->count,
sizeof flist->files[0], (int (*)())file_compare);
qsort(flist->files, flist->count,
sizeof flist->files[0], (int (*)())file_compare);
for (i = no_dups? 0 : flist->count; i < flist->count; i++) {
if (flist->files[i]->basename) {
for (i = no_dups? 0 : flist->count; i < flist->count; i++) {
if (flist->files[i]->basename) {
if (!*c2) {
switch (state2) {
case s_DIR:
if (!*c2) {
switch (state2) {
case s_DIR:
+ if (state1 == s_SLASH && sorting_flist) {
+ int j;
+ /* Optimize for future comparisons. */
+ for (j = 0;
+ j < sorting_flist->count;
+ j++) {
+ struct file_struct *fp
+ = sorting_flist->files[j];
+ if (fp->dirname == f2->dirname)
+ fp->dirname = f1->dirname;
+ }
+ }
state2 = s_SLASH;
c2 = (uchar*)"/";
break;
state2 = s_SLASH;
c2 = (uchar*)"/";
break;