Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 6F665431FD0 for ; Tue, 12 Jul 2011 18:55:59 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L1M1zKDnSHEL for ; Tue, 12 Jul 2011 18:55:56 -0700 (PDT) Received: from imarko.xen.prgmr.com (imarko.xen.prgmr.com [72.13.95.244]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D9FFD431FB6 for ; Tue, 12 Jul 2011 18:55:56 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=zsu.kismala.com) by imarko.xen.prgmr.com with esmtp (Exim 4.75) (envelope-from ) id 1Qgog7-0003rC-Va; Tue, 12 Jul 2011 18:55:56 -0700 From: Istvan Marko To: Austin Clements Subject: Re: Slowness (search opens every email file?) References: <20110711190721.GA5386@compy.jasonwoof.org> <20110712202459.GB15019@compy.jasonwoof.org> Date: Tue, 12 Jul 2011 18:55:55 -0700 In-Reply-To: (Austin Clements's message of "Tue, 12 Jul 2011 20:50:56 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Cc: Notmuch Mail X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2011 01:55:59 -0000 --=-=-= Content-Type: text/plain Austin Clements writes: > Istvan, did you make any progress on this patch since the last > version? I seem to recall it just needed general cleanup (code style > and such) and a better answer for backwards compatibility (the > unfortunate " " thing). I have been using the version that encodes empty headers to " " but another way to handle this is to simply not set a VALUE for empty headers and then fall back to the original parsing method for these messages. Emails without from/subject/message-id headers are not very common so perhaps this is a good compromise. Below is the patch without the " " hack. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=notmuch-value2.patch diff --git a/lib/database.cc b/lib/database.cc index 9c2f4ec..63a15bb 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -1654,7 +1654,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch, goto DONE; date = notmuch_message_file_get_header (message_file, "date"); - _notmuch_message_set_date (message, date); + _notmuch_message_set_header_values (message, date, from, subject); _notmuch_message_index_file (message, filename); } else { diff --git a/lib/message.cc b/lib/message.cc index d993cde..48a31f5 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -410,6 +410,20 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message) const char * notmuch_message_get_header (notmuch_message_t *message, const char *header) { + std::string value; + + // fetch header from the appropriate xapian value field if available + if (strcmp(header,"from") == 0) + value=message->doc.get_value(NOTMUCH_VALUE_FROM); + else if (strcmp(header,"subject") == 0) + value=message->doc.get_value (NOTMUCH_VALUE_SUBJECT); + else if (strcmp(header,"message-id") == 0) + value=message->doc.get_value (NOTMUCH_VALUE_MESSAGE_ID); + + if (!value.empty()) + return talloc_strdup (message, value.c_str ()); + + // otherwise fall back to parsing the file _notmuch_message_ensure_message_file (message); if (message->message_file == NULL) return NULL; @@ -785,8 +799,10 @@ notmuch_message_set_author (notmuch_message_t *message, } void -_notmuch_message_set_date (notmuch_message_t *message, - const char *date) +_notmuch_message_set_header_values (notmuch_message_t *message, + const char *date, + const char *from, + const char *subject) { time_t time_value; @@ -799,6 +815,8 @@ _notmuch_message_set_date (notmuch_message_t *message, message->doc.add_value (NOTMUCH_VALUE_TIMESTAMP, Xapian::sortable_serialise (time_value)); + message->doc.add_value (NOTMUCH_VALUE_FROM, from); + message->doc.add_value (NOTMUCH_VALUE_SUBJECT, subject); } /* Synchronize changes made to message->doc out into the database. */ diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 02e24ee..2e91afd 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -111,7 +111,9 @@ _internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2); typedef enum { NOTMUCH_VALUE_TIMESTAMP = 0, - NOTMUCH_VALUE_MESSAGE_ID + NOTMUCH_VALUE_MESSAGE_ID, + NOTMUCH_VALUE_FROM, + NOTMUCH_VALUE_SUBJECT } notmuch_value_t; /* Xapian (with flint backend) complains if we provide a term longer @@ -287,9 +289,10 @@ void _notmuch_message_ensure_thread_id (notmuch_message_t *message); void -_notmuch_message_set_date (notmuch_message_t *message, - const char *date); - +_notmuch_message_set_header_values (notmuch_message_t *message, + const char *date, + const char *from, + const char *subject); void _notmuch_message_sync (notmuch_message_t *message); --=-=-= Content-Type: text/plain -- Istvan --=-=-=--