- if ((sort == NOTMUCH_SORT_OLDEST_FIRST && date <= thread->newest) ||
- (sort != NOTMUCH_SORT_OLDEST_FIRST && date == thread->newest)) {
- thread->subject = talloc_strdup (thread, cleaned_subject);
- }
+ if (thread->subject)
+ talloc_free (thread->subject);
+
+ thread->subject = talloc_strdup (thread, cleaned_subject);
+}
+
+static void
+_thread_add_matched_message (notmuch_thread_t *thread,
+ notmuch_message_t *message,
+ notmuch_sort_t sort)
+{
+ time_t date;
+ notmuch_message_t *hashed_message;
+
+ date = notmuch_message_get_date (message);
+
+ if (date < thread->oldest || ! thread->matched_messages)
+ thread->oldest = date;
+
+ if (date > thread->newest || ! thread->matched_messages)
+ thread->newest = date;