From: Pierre Habouzit Date: Mon, 28 May 2007 11:37:59 +0000 (+0200) Subject: remove option OPTSAVEUNSUB. This sucks, writing 2Mo of file is easy. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=94d1107856bbba2b77fbd3c0512b9e18f6ed574b;p=apps%2Fmadmutt.git remove option OPTSAVEUNSUB. This sucks, writing 2Mo of file is easy. Also fix performance issue with tailing in newsgroup list. Signed-off-by: Pierre Habouzit --- diff --git a/browser.c b/browser.c index ddc6b47..6e24df9 100644 --- a/browser.c +++ b/browser.c @@ -1428,7 +1428,6 @@ void mutt_select_file (char *f, ssize_t flen, int flags, char ***files, init_menu (&state, menu, title, sizeof (title), buffy); } mutt_newsrc_update (news); - nntp_clear_cacheindex (news); if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE) regfree (rx); p_delete(&rx); diff --git a/init.h b/init.h index 6f008bc..e99e78a 100644 --- a/init.h +++ b/init.h @@ -2256,15 +2256,6 @@ struct option_t MuttVars[] = { ** If \fIset\fP, Madmutt will prompt you for the \fTFollowup-To:\fP header ** field before editing the body of an outgoing news article. */ - {"nntp_save_unsubscribed", DT_BOOL, R_NONE, OPTSAVEUNSUB, "no" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** When \fIset\fP, info about unsubscribed newsgroups will be saved into the - ** ``newsrc'' file and into the news cache. - */ {"nntp_show_new_news", DT_BOOL, R_NONE, OPTSHOWNEWNEWS, "yes" }, /* ** .pp diff --git a/mutt.h b/mutt.h index df6c5f8..d324819 100644 --- a/mutt.h +++ b/mutt.h @@ -310,7 +310,6 @@ enum { #ifdef USE_NNTP OPTSHOWNEWNEWS, OPTSHOWONLYUNREAD, - OPTSAVEUNSUB, OPTLOADDESC, #endif /* USE_NNTP */ diff --git a/nntp.c b/nntp.c index eb5cd42..a533933 100644 --- a/nntp.c +++ b/nntp.c @@ -47,7 +47,8 @@ static void mutt_newsgroup_stat(nntp_data_t *data) for (int i = 0; i < data->num; i++) { int first = MAX(data->entries[i].first, data->firstMessage); int last = MIN(data->entries[i].last, data->lastMessage); - data->unread -= MAX(0, last - first + 1); + if (first <= last) + data->unread -= last - first + 1; } } @@ -76,7 +77,7 @@ static int nntp_parse_newsrc_line(nntp_server_t * news, const char *line) if (news->newsgroups->nelem < news->newsgroups->curnelem * 2) hash_resize (news->newsgroups, news->newsgroups->nelem * 2); hash_insert(news->newsgroups, data->group, data); - nntp_data_list_append(&news->list, data); + news->tail = nntp_data_list_append(news->tail, data); } else { p_delete(&data->entries); } @@ -203,7 +204,7 @@ static int nntp_parse_cacheindex(nntp_server_t *news) if (news->newsgroups->nelem < news->newsgroups->curnelem * 2) hash_resize (news->newsgroups, news->newsgroups->nelem * 2); hash_insert (news->newsgroups, data->group, data); - nntp_data_list_append(&news->list, data); + news->tail = nntp_data_list_append(news->tail, data); } m_strreplace(&data->cache, p); @@ -293,7 +294,7 @@ static int add_group (char *buf, void *serv) if (s->newsgroups->nelem < s->newsgroups->curnelem * 2) hash_resize (s->newsgroups, s->newsgroups->nelem * 2); hash_insert(s->newsgroups, nntp_data->group, nntp_data); - nntp_data_list_append(&s->list, nntp_data); + s->tail = nntp_data_list_append(s->tail, nntp_data); } nntp_data->deleted = 0; nntp_data->firstMessage = first; @@ -403,7 +404,6 @@ nntp_server_t *mutt_select_newsserver (char *server) list->subscribed = list->rc = list->num = 0; } slurp_newsrc (serv); - nntp_clear_cacheindex (serv); } if (serv->status == NNTP_BYE) @@ -414,9 +414,10 @@ nntp_server_t *mutt_select_newsserver (char *server) /* New newsserver */ serv = p_new(nntp_server_t, 1); + serv->tail = &serv->list; serv->conn = conn; serv->newsrc = m_strdup(file); - serv->newsgroups = hash_new(1009, false); + serv->newsgroups = hash_new(SHRT_MAX, false); slurp_newsrc (serv); /* load .newsrc */ nntp_parse_cacheindex (serv); /* load .index */ if (nntp.use_cache && serv->cache && nntp_get_cache_all (serv) >= 0) @@ -429,7 +430,6 @@ nntp_server_t *mutt_select_newsserver (char *server) p_delete(&serv); return NULL; } - nntp_clear_cacheindex (serv); conn->data = (void *) serv; return serv; @@ -764,22 +764,6 @@ static void nntp_delete_cache (nntp_data_t * data) NULL); } -/* Remove cache files of unsubscribed newsgroups */ -void nntp_clear_cacheindex (nntp_server_t * news) -{ - nntp_data_t *data; - - if (option (OPTSAVEUNSUB) || !news) - return; - - for (data = news->list; data; data = data->next) { - if (!data || data->subscribed || !data->cache) - continue; - nntp_delete_cache (data); - } - return; -} - static int nntp_save_cache_index (nntp_server_t * news) { char buf[HUGE_STRING]; @@ -927,7 +911,7 @@ nntp_data_t *mutt_newsgroup_subscribe (nntp_server_t * news, char *group) if (news->newsgroups->nelem < news->newsgroups->curnelem * 2) hash_resize (news->newsgroups, news->newsgroups->nelem * 2); hash_insert (news->newsgroups, data->group, data); - nntp_data_list_append(&news->list, data); + news->tail = nntp_data_list_append(news->tail, data); } if (!data->subscribed) { data->subscribed = 1; @@ -945,8 +929,6 @@ nntp_data_t *mutt_newsgroup_unsubscribe (nntp_server_t * news, char *group) return NULL; if (data->subscribed) { data->subscribed = 0; - if (!option (OPTSAVEUNSUB)) - data->rc = 0; } return data; } @@ -1832,7 +1814,7 @@ static int nntp_open_mailbox (CONTEXT * ctx) nntp_data = nntp_data_new(); nntp_data->group = m_strdup(buf); hash_insert(serv->newsgroups, nntp_data->group, nntp_data); - nntp_data_list_append(&serv->list, nntp_data); + serv->tail = nntp_data_list_append(serv->tail, nntp_data); } ctx->data = nntp_data; nntp_data->nserv = serv; @@ -1865,6 +1847,8 @@ static int nntp_open_mailbox (CONTEXT * ctx) if ((*l) == nntp_data) { nntp_data_list_pop(l); nntp_data_delete(&nntp_data); + if (!*l) + serv->tail = l; break; } } @@ -2090,10 +2074,8 @@ static int nntp_sync_mailbox (CONTEXT * ctx, int unused1, int* unused2) { nntp_data_t *data = ctx->data; - /* CACHE: update cache and .index files */ - if ((option (OPTSAVEUNSUB) || data->subscribed)) - nntp_save_cache_group (ctx); - nntp_free_acache (data); + nntp_save_cache_group(ctx); + nntp_free_acache(data); data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */ return 0; @@ -2301,7 +2283,8 @@ int nntp_get_active (nntp_server_t * serv) tmp = &(*tmp)->next; } } - nntp_save_cache_index (serv); + serv->tail = tmp; + nntp_save_cache_index(serv); mutt_clear_error (); return nntp.checked; diff --git a/nntp.h b/nntp.h index 6d10aec..9e8d1f7 100644 --- a/nntp.h +++ b/nntp.h @@ -44,6 +44,7 @@ typedef struct nntp_server_t { time_t check_time; hash_t *newsgroups; nntp_data_t *list; /* list of newsgroups */ + nntp_data_t **tail; CONNECTION *conn; } nntp_server_t; @@ -91,7 +92,6 @@ nntp_data_t *mutt_newsgroup_subscribe (nntp_server_t *, char *); nntp_data_t *mutt_newsgroup_unsubscribe (nntp_server_t *, char *); nntp_data_t *mutt_newsgroup_catchup (nntp_server_t *, char *); nntp_data_t *mutt_newsgroup_uncatchup (nntp_server_t *, char *); -void nntp_clear_cacheindex (nntp_server_t *); int mutt_newsrc_update (nntp_server_t *); int nntp_close_mailbox (CONTEXT *); int nntp_fetch_message (MESSAGE *, CONTEXT *, int);