summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1998-11-09 11:15:28 +0000
committerThomas Roessler <roessler@does-not-exist.org>1998-11-09 11:15:28 +0000
commitbeffff0bc46c6616fc172dc79c5cbd14cbf52313 (patch)
tree792637851a0ba8ee74eea95f23a5527428f0779b
parent7bfbde79aef778539881dffef946892fdf7231c1 (diff)
Fix an efficiency problem with the color index features.
-rw-r--r--color.c11
-rw-r--r--curs_main.c17
-rw-r--r--protos.h1
-rw-r--r--score.c4
-rw-r--r--sort.c2
5 files changed, 19 insertions, 16 deletions
diff --git a/color.c b/color.c
index 8aa7596e..1d7ea013 100644
--- a/color.c
+++ b/color.c
@@ -428,8 +428,11 @@ _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err,
if (do_cache && !option (OPTNOCURSES))
{
- mutt_cache_index_colors (Context);
+ int i;
set_option (OPTFORCEREDRAWINDEX);
+ /* force re-caching of index colors */
+ for (i = 0; Context && i < Context->msgcount; i++)
+ Context->hdrs[i]->pair = 0;
}
return (0);
}
@@ -504,6 +507,8 @@ add_pattern (COLOR_LINE **top, const char *s, int sensitive,
#endif
if (is_index)
{
+ int i;
+
strfcpy(buf, tmp->pattern, sizeof(buf));
mutt_check_simple (buf, sizeof (buf), NONULL(SimpleSearch));
if((tmp->color_pattern = mutt_pattern_comp (buf, M_FULL_MSG, err)) == NULL)
@@ -511,6 +516,9 @@ add_pattern (COLOR_LINE **top, const char *s, int sensitive,
mutt_free_color_line(&tmp, 1);
return -1;
}
+ /* force re-caching of index colors */
+ for (i = 0; Context && i < Context->msgcount; i++)
+ Context->hdrs[i]->pair = 0;
}
tmp->pair = attr;
*top = tmp;
@@ -696,7 +704,6 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err,
else if (object == MT_COLOR_INDEX)
{
r = add_pattern (&ColorIndexList, buf->data, 1, fg, bg, attr, err, 1);
- mutt_cache_index_colors(Context);
set_option (OPTFORCEREDRAWINDEX);
}
else if (object == MT_COLOR_QUOTED)
diff --git a/curs_main.c b/curs_main.c
index 95825911..a5729186 100644
--- a/curs_main.c
+++ b/curs_main.c
@@ -138,7 +138,13 @@ void index_make_entry (char *s, size_t l, MUTTMENU *menu, int num)
int index_color (int index_no)
{
- return Context->hdrs[Context->v2r[index_no]]->pair;
+ HEADER *h = Context->hdrs[Context->v2r[index_no]];
+
+ if (h->pair)
+ return h->pair;
+
+ mutt_set_header_color (Context, h);
+ return h->pair;
}
static int ci_next_undeleted (int msgno)
@@ -1730,12 +1736,3 @@ void mutt_set_header_color (CONTEXT *ctx, HEADER *curhdr)
}
curhdr->pair = ColorDefs[MT_COLOR_NORMAL];
}
-
-void mutt_cache_index_colors (CONTEXT *ctx)
-{
- int i;
-
- if (ctx)
- for (i = 0; i < ctx->msgcount; i++)
- mutt_set_header_color (ctx, ctx->hdrs[i]);
-}
diff --git a/protos.h b/protos.h
index 3f33b3eb..60b8e9a6 100644
--- a/protos.h
+++ b/protos.h
@@ -273,7 +273,6 @@ int mutt_write_mime_body (BODY *, FILE *);
int mutt_write_mime_header (BODY *, FILE *);
int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, int);
int mutt_yesorno (const char *, int);
-void mutt_cache_index_colors(CONTEXT *);
void mutt_set_header_color(CONTEXT *, HEADER *);
int mutt_save_confirm (const char *, struct stat *);
diff --git a/score.c b/score.c
index 642fb3eb..12d6bd2e 100644
--- a/score.c
+++ b/score.c
@@ -54,7 +54,9 @@ void mutt_check_rescore (CONTEXT *ctx)
for (i = 0; i < ctx->msgcount; i++)
mutt_score_message (ctx->hdrs[i]);
- mutt_cache_index_colors (ctx);
+ /* force re-caching of index colors */
+ for (i = 0; ctx && i < ctx->msgcount; i++)
+ ctx->hdrs[i]->pair = 0;
unset_option (OPTNEEDRESCORE);
}
diff --git a/sort.c b/sort.c
index 5e89f856..17898ecc 100644
--- a/sort.c
+++ b/sort.c
@@ -255,8 +255,6 @@ void mutt_sort_headers (CONTEXT *ctx, int init)
cur->collapsed = 0;
}
- mutt_cache_index_colors(ctx);
-
if (!ctx->quiet)
mutt_clear_error ();
}