From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] ox: Cache locations of fuzzy links Date: Wed, 01 May 2013 23:46:17 +0200 Message-ID: <87vc72idau.fsf@gmail.com> References: <877gjnojsq.fsf@Rainer.invalid> <5654CA29-5F6D-4E8B-8B8B-C3609D76D189@gmail.com> <8761z5gw6w.fsf@gmx.li> <87zjwhxjla.fsf@Rainer.invalid> <87bo8uyjtc.fsf_-_@gmx.li> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:39351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXeqz-0003Vr-9I for emacs-orgmode@gnu.org; Wed, 01 May 2013 17:46:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXeqy-0006Dg-4i for emacs-orgmode@gnu.org; Wed, 01 May 2013 17:46:21 -0400 Received: from mail-we0-x233.google.com ([2a00:1450:400c:c03::233]:64684) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXeqx-0006Da-UN for emacs-orgmode@gnu.org; Wed, 01 May 2013 17:46:20 -0400 Received: by mail-we0-f179.google.com with SMTP id u7so36794wey.10 for ; Wed, 01 May 2013 14:46:19 -0700 (PDT) In-Reply-To: <87bo8uyjtc.fsf_-_@gmx.li> (Lawrence Mitchell's message of "Wed, 01 May 2013 13:18:55 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Lawrence Mitchell Cc: emacs-orgmode@gnu.org Hello, Lawrence Mitchell writes: > * ox.el (org-export-resolve-fuzzy-link): Look for fuzzy link in a > cache before trying to resolve it in the parse tree. Thanks for your patch. A few comments follow. > - (if match-title-p (substring raw-path 1) raw-path)))) > + (if match-title-p (substring raw-path 1) raw-path))) > + (link-cache (plist-get info :fuzzy-link-cache))) > + ;; Cache for locations of fuzzy links that are not position dependent > + (unless link-cache > + (setq info (plist-put info :fuzzy-link-cache > + (make-hash-table :test 'equal))) > + (setq link-cache (plist-get info :fuzzy-link-cache))) Minor nitpick: I'd rather have this included in the (let ...), like: (let (... (link-cache (or (plist-get info :fuzzy-link-cache) (plist-get (setq info (plist-put info :fuzzy-link-cache (make-hash-table :test 'eq))) :fuzzy-link-cache))))) > - (org-element-map (plist-get info :parse-tree) 'target > - (lambda (blob) > - (and (equal (org-split-string (org-element-property :value blob)) > - path) > - blob)) > - info t))) > + (let ((found (gethash (cons 'path path) > + link-cache > + 'fuzzy-link-not-found))) > + (or (not (eq found 'fuzzy-link-not-found)) > + (puthash (cons 'path path) > + (org-element-map (plist-get info :parse-tree) 'target > + (lambda (blob) > + (and (equal (org-split-string > + (org-element-property :value blob)) > + path) > + blob)) > + info t) > + link-cache))))) I don't get why you need to use such a key. Simply use the link as key and `eq' as the test. Regards, -- Nicolas Goaziou