don't resize the hash, 32k elements are way enough.
authorPierre Habouzit <madcoder@debian.org>
Mon, 28 May 2007 13:10:55 +0000 (15:10 +0200)
committerPierre Habouzit <madcoder@debian.org>
Mon, 28 May 2007 13:10:55 +0000 (15:10 +0200)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
nntp.c

diff --git a/nntp.c b/nntp.c
index d3bf60f..a61bcf8 100644 (file)
--- a/nntp.c
+++ b/nntp.c
@@ -47,8 +47,7 @@ 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);
-        if (first <= last)
-            data->unread -= last - first + 1;
+        data->unread -= MAX(0, last - first + 1);
     }
 }
 
@@ -74,8 +73,6 @@ static int nntp_parse_newsrc_line(nntp_server_t *news, const char *line)
         data->group = p_dupstr(line, p - line);
         data->nserv = news;
         data->deleted = 1;
-        if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
-            hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
         hash_insert(news->newsgroups, data->group, data);
         news->tail = nntp_data_list_append(news->tail, data);
     } else {
@@ -202,8 +199,6 @@ static int nntp_parse_cacheindex(nntp_server_t *news)
                 data->group = m_strdup(buf);
                 data->nserv = news;
                 data->deleted = 1;
-                if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
-                    hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
                 hash_insert (news->newsgroups, data->group, data);
                 news->tail = nntp_data_list_append(news->tail, data);
             }
@@ -292,8 +287,6 @@ static int add_group (char *buf, void *serv)
     nntp_data = nntp_data_new();
     nntp_data->group = m_strdup(group);
     nntp_data->nserv = s;
-    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);
     s->tail = nntp_data_list_append(s->tail, nntp_data);
   }
@@ -909,8 +902,6 @@ nntp_data_t *mutt_newsgroup_subscribe (nntp_server_t * news, char *group)
     data->group = m_strdup(group);
     data->nserv = news;
     data->deleted = 1;
-    if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
-        hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
     hash_insert (news->newsgroups, data->group, data);
     news->tail = nntp_data_list_append(news->tail, data);
   }