Projects STRLCPY neomutt Commits c6aae8ac
🤬
  • avoid reapplying limit patterns on already-limited emails

    currently, whenever we update the index, we also re-apply the index
    pattern on all messages. this is problematic because (a) this can be
    slow and (b) if a user has been working with a limited index, an
    incoming new message can suddenly alter that index.
    
    we attempt to avoid re-applying the limit to all messages, and instead
    only apply it to new messages. to do this, we keep track, in the `Email`
    struct, of whether the message has already had the limit applied via a
    boolean `limit_visited` flag. we retain existing visiblity settings for
    those messages, and only apply new visibility settings when
    `limit_visited` is not already set.
  • Loading...
  • c6aae8ac
    1 parent 4974ff3c
  • ■ ■ ■ ■ ■
    email/email.h
    skipped 118 lines
    119 119   struct MuttThread *thread; ///< Thread of Emails
    120 120   bool collapsed : 1; ///< Is this message part of a collapsed thread?
    121 121   bool visible : 1; ///< Is this message part of the view?
     122 + bool limit_visited : 1; ///< Has the limit pattern been applied to this message?
    122 123   size_t num_hidden; ///< Number of hidden messages in this view
    123 124   ///< (only valid when collapsed is set)
    124 125   char *tree; ///< Character string to print thread tree
    skipped 76 lines
  • ■ ■ ■ ■ ■ ■
    index/dlg_index.c
    skipped 428 lines
    429 429   
    430 430   if (lmt)
    431 431   {
    432  - /* Because threading changes the order in m->emails, we don't
    433  - * know which emails are new. Hence, we need to re-apply the limit to the
    434  - * whole set.
    435  - */
    436 432   for (int i = 0; i < m->msg_count; i++)
    437 433   {
    438 434   struct Email *e = m->emails[i];
    439  - if ((e->vnum != -1) || mutt_pattern_exec(SLIST_FIRST(mv->limit_pattern),
    440  - MUTT_MATCH_FULL_ADDRESS, m, e, NULL))
     435 + 
     436 + if ((e->limit_visited && e->visible) ||
     437 + mutt_pattern_exec(SLIST_FIRST(mv->limit_pattern),
     438 + MUTT_MATCH_FULL_ADDRESS, m, e, NULL))
    441 439   {
    442 440   /* vnum will get properly set by mutt_set_vnum(), which
    443 441   * is called by mutt_sort_headers() just below. */
    skipped 5 lines
    449 447   e->vnum = -1;
    450 448   e->visible = false;
    451 449   }
     450 + 
     451 + // mark email as visited so we don't re-apply the pattern next time
     452 + e->limit_visited = true;
    452 453   }
    453 454   /* Need a second sort to set virtual numbers and redraw the tree */
    454 455   mutt_sort_headers(m, mv->threads, false, &mv->vsize);
    skipped 43 lines
    498 499   struct Email *e = mv->mailbox->emails[i];
    499 500   if (!e)
    500 501   break;
    501  - if (mutt_pattern_exec(SLIST_FIRST(mv->limit_pattern),
     502 + 
     503 + if ((e->limit_visited && e->visible) ||
     504 + mutt_pattern_exec(SLIST_FIRST(mv->limit_pattern),
    502 505   MUTT_MATCH_FULL_ADDRESS, mv->mailbox, e, NULL))
    503 506   {
    504 507   assert(mv->mailbox->vcount < mv->mailbox->msg_count);
    skipped 8 lines
    513 516   {
    514 517   e->visible = false;
    515 518   }
     519 + 
     520 + // mark email as visited so we don't re-apply the pattern next time
     521 + e->limit_visited = true;
    516 522   }
    517 523   }
    518 524   
    skipped 928 lines
  • ■ ■ ■ ■ ■ ■
    pattern/pattern.c
    skipped 406 lines
    407 407   /* new limit pattern implicitly uncollapses all threads */
    408 408   e->vnum = -1;
    409 409   e->visible = false;
     410 + e->limit_visited = true;
    410 411   e->collapsed = false;
    411 412   e->num_hidden = 0;
     413 + 
    412 414   if (match_all ||
    413 415   mutt_pattern_exec(SLIST_FIRST(pat), MUTT_MATCH_FULL_ADDRESS, m, e, NULL))
    414 416   {
    skipped 389 lines
Please wait...
Page is in error, reload to recover