Browse Source

pre-sort exception list passed to driver->load_box()

... and use that to optimize the maildir driver somewhat.
wip/uidval-recovery
Oswald Buddenhagen 8 years ago
parent
commit
ae95490d52
  1. 1
      src/common.h
  2. 1
      src/drv_imap.c
  3. 9
      src/drv_maildir.c
  4. 1
      src/sync.c
  5. 17
      src/util.c

1
src/common.h

@ -167,6 +167,7 @@ int map_name( const char *arg, char **result, int reserve, const char *in, const
DEFINE_ARRAY_TYPE(int)
void sort_int_array( int_array_t array );
int find_int_array( const int_array_t array, int value );
void arc4_init( void );
uchar arc4_getbyte( void );

1
src/drv_imap.c

@ -2305,7 +2305,6 @@ imap_load_box( store_t *gctx, int minuid, int maxuid, int newuid, int_array_t ex
} else {
struct imap_cmd_refcounted_state *sts = imap_refcounted_new_state( cb, aux );
sort_int_array( excs );
for (i = 0; i < excs.size; ) {
for (bl = 0; i < excs.size && bl < 960; i++) {
if (bl)

9
src/drv_maildir.c

@ -831,7 +831,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
DBC *dbc;
#endif /* USE_DB */
msg_t *entry;
int i, j, uid, bl, fnl, ret;
int i, uid, bl, fnl, ret;
time_t now, stamps[2];
struct stat st;
char buf[_POSIX_PATH_MAX], nbuf[_POSIX_PATH_MAX];
@ -922,13 +922,8 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
uid = INT_MAX;
}
if (uid <= ctx->maxuid) {
if (uid < ctx->minuid) {
for (j = 0; j < ctx->excs.size; j++)
if (ctx->excs.data[j] == uid)
goto oke;
if (uid < ctx->minuid && !find_int_array( ctx->excs, uid ))
continue;
oke: ;
}
entry = msg_t_array_append( msglist );
entry->base = nfstrdup( e->d_name );
entry->uid = uid;

1
src/sync.c

@ -1276,6 +1276,7 @@ box_opened2( sync_vars_t *svars, int t )
minwuid = INT_MAX;
}
sync_ref( svars );
sort_int_array( mexcs.array );
load_box( svars, M, minwuid, mexcs.array );
if (!check_cancel( svars ))
load_box( svars, S, (ctx[S]->opts & OPEN_OLD) ? 1 : INT_MAX, (int_array_t){ 0, 0 } );

17
src/util.c

@ -545,6 +545,23 @@ sort_int_array( int_array_t array )
qsort( array.data, array.size, sizeof(int), compare_ints );
}
int
find_int_array( int_array_t array, int value )
{
int bot = 0, top = array.size - 1;
while (bot <= top) {
int i = (bot + top) / 2;
int elt = array.data[i];
if (elt == value)
return 1;
if (elt < value)
bot = i + 1;
else
top = i - 1;
}
return 0;
}
static struct {
uchar i, j, s[256];

Loading…
Cancel
Save