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 CAC38431FB6 for ; Fri, 4 Feb 2011 13:45:11 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -5 X-Spam-Level: X-Spam-Status: No, score=-5 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_HI=-5] 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 rVyzu0IWKlpE for ; Fri, 4 Feb 2011 13:45:10 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by olra.theworths.org (Postfix) with ESMTP id A414A431FB5 for ; Fri, 4 Feb 2011 13:45:10 -0800 (PST) Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p14LjAi6003573 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 4 Feb 2011 16:45:10 -0500 Received: from nb.net.home (vpn-238-160.phx2.redhat.com [10.3.238.160]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p14Lj8JO024777; Fri, 4 Feb 2011 16:45:09 -0500 From: Karel Zak To: notmuch@notmuchmail.org Subject: [PATCH] new: read db_files and db_subdirs if mtime changed Date: Fri, 4 Feb 2011 22:44:31 +0100 Message-Id: <1296855871-15702-1-git-send-email-kzak@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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: Fri, 04 Feb 2011 21:45:11 -0000 The db_files and db_subdirs are unnecessary for unchanged directories. maildir with 10000 e-mails: old version: $ time ./notmuch new No new mail. real 0m0.053s user 0m0.028s sys 0m0.026s new version: $ time ./notmuch new No new mail. real 0m0.032s user 0m0.009s sys 0m0.023s Signed-off-by: Karel Zak --- notmuch-new.c | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index 941f9d6..31d4553 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -247,15 +247,7 @@ add_files_recursive (notmuch_database_t *notmuch, directory = notmuch_database_get_directory (notmuch, path); db_mtime = notmuch_directory_get_mtime (directory); - if (db_mtime == 0) { - new_directory = TRUE; - db_files = NULL; - db_subdirs = NULL; - } else { - new_directory = FALSE; - db_files = notmuch_directory_get_child_files (directory); - db_subdirs = notmuch_directory_get_child_directories (directory); - } + new_directory = db_mtime ? FALSE : TRUE; /* If the database knows about this directory, then we sort based * on strcmp to match the database sorting. Otherwise, we can do @@ -328,6 +320,11 @@ add_files_recursive (notmuch_database_t *notmuch, if (fs_mtime == db_mtime) goto DONE; + if (!new_directory) { + db_files = notmuch_directory_get_child_files (directory); + db_subdirs = notmuch_directory_get_child_directories (directory); + } + /* Pass 2: Scan for new files, removed files, and removed directories. */ for (i = 0; i < num_fs_entries; i++) { -- 1.7.3.4