Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 4CA5B6DE1A32 for ; Tue, 21 Apr 2015 19:23:02 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -1.21 X-Spam-Level: X-Spam-Status: No, score=-1.21 tagged_above=-999 required=5 tests=[AWL=1.641, RCVD_IN_DNSWL_MED=-2.3, RP_MATCHES_RCVD=-0.55, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QpuZJvg4tpVG for ; Tue, 21 Apr 2015 19:23:00 -0700 (PDT) Received: from outgoing.csail.mit.edu (outgoing.csail.mit.edu [128.30.2.149]) by arlo.cworth.org (Postfix) with ESMTP id 03E316DE1A2E for ; Tue, 21 Apr 2015 19:22:59 -0700 (PDT) Received: from [104.131.20.129] (helo=awakeningjr) by outgoing.csail.mit.edu with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1YkkJW-0003TY-EU; Tue, 21 Apr 2015 22:22:58 -0400 Received: from amthrax by awakeningjr with local (Exim 4.84) (envelope-from ) id 1YkkJV-0007Se-E6; Tue, 21 Apr 2015 22:22:57 -0400 Date: Tue, 21 Apr 2015 22:22:57 -0400 From: Austin Clements To: Ronny Chevalier Subject: Re: notmuch_thread_get_authors Message-ID: <20150422022257.GN19324@csail.mit.edu> References: <87618qfk5l.fsf@maritornes.cs.unb.ca> <87lhhlhryd.fsf@csail.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.18 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, 22 Apr 2015 02:23:02 -0000 Quoth Ronny Chevalier on Apr 22 at 4:01 am: > On Wed, Apr 22, 2015 at 3:28 AM, Austin Clements > wrote: > > On Tue, 21 Apr 2015, Ronny Chevalier wrote: > >> On Tue, Apr 21, 2015 at 1:35 AM, David Bremner wrote: > >>> Ronny Chevalier writes: > >> Austin Clements wrote: > >>> And I think there's a fairly easy way to do it in C code that will > >>> also prevent library interface bloat: instead of introducing new > >>> library APIs to get at this information, just use the existing > >>> notmuch_thread_get_messages API and construct the matched and > >>> non-matched lists in the CLI. Doing it in the CLI wouldn't require > >>> the library to export yet another string list structure, which is > >>> always a huge pain (thanks C!), and wouldn't introduce more "helper" > >>> functions into the library API. > >> > >> I disagree with what Austin said. Because this does not solve the > >> issue at all (or I misunderstood). The issue is with the notmuch API, > >> if someone is using this library there no way it can parse properly > >> the authors. > >> In my case I am not using the CLI but the notmuch library, fixing this > >> in the CLI is just an hack, and it does not fix the issue for the > >> library users. > > > > My suggestion was in no way specific to the CLI. That was the context of > > the discussion at the time, but for the purposes of this discussion, the > > CLI is just another library user. > > Ok, sorry for misunderstanding. > > > > > You're completely right that there's no way to reliably parse the > > authors list returned by notmuch_thread_get_authors. So don't do > > that. Just use notmuch_thread_get_messages, walk the messages list, and > > build your own authors list. There's no need to introduce additional > > complexity and surface area into the library API for this specific use > > case (IMO, even notmuch_thread_get_authors shouldn't exist, but it's > > there for legacy reasons.) Then you can get author lists for matched, > > non-matched, matching a specific tag, just the to, just the from, counts > > of how many times each author appeared, whatever you want. > > > > Ok thanks! > > If I read the code correctly, _notmuch_thread_create in lib/thread.cc > process every message to get information like tags, subject and > authors. Since notmuch_thread_get_authors is here for legacy reasons, > would it be better to generate the list of authors only when requested > with notmuch_thread_get_authors (and cache the result of course)? > Because, new code will not use this and will do this work manually, > the generation of the list in intern consumes resources for nothing. It might be worth making this lazy. I'd be surprised if this has noticeable CPU or memory cost in the grand scheme of putting together a thread, but I don't have any numbers to back this up.