]> granicus.if.org Git - mutt/commitdiff
Fix an efficiency problem with the color index features.
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 9 Nov 1998 11:15:28 +0000 (11:15 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 9 Nov 1998 11:15:28 +0000 (11:15 +0000)
color.c
curs_main.c
protos.h
score.c
sort.c

diff --git a/color.c b/color.c
index 8aa7596ee948cf2fc84cce4302f1a04a680337e8..1d7ea013812a933306eeab369fdb12b7417bc602 100644 (file)
--- 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)
index 958259119a596f651bb13edab1de201d72bfa69f..a5729186be62a099e1535604bd64892c6f78498e 100644 (file)
@@ -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]);
-}
index 3f33b3ebfd6ec9d7a0aefe711f7b7a1704272bf5..60b8e9a6ad53321065d349629cb3b7be352b0863 100644 (file)
--- 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 642fb3ebaa71f7729fcb5b8979ccc4e8cd490284..12d6bd2e001b4fc0922884888c40aeea7980e19b 100644 (file)
--- 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 5e89f85618658cee69cffe3ae550d3fcbc3553f8..17898ecc2d02c205d12af03a15bea368f159b06f 100644 (file)
--- 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 ();
 }