]> code.delx.au - gnu-emacs-elpa/commitdiff
company--capf-data: use caching
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 24 Aug 2014 16:51:52 +0000 (20:51 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 24 Aug 2014 16:51:52 +0000 (20:51 +0400)
#170

company-capf.el

index e27ae7a4609c5854200fd259ae596c815551b3eb..b630025690f498063f554fb75463d2c07fa0f678 100644 (file)
 (require 'company)
 (require 'cl-lib)
 
+(defvar company--capf-cache nil)
+
 (defun company--capf-data ()
+  (let ((cache company--capf-cache))
+    (if (and (equal (current-buffer) (car cache))
+             (equal (point) (car (setq cache (cdr cache))))
+             (equal (buffer-chars-modified-tick) (car (setq cache (cdr cache)))))
+        (cadr cache)
+      (let ((data (company--capf-data-real)))
+        (setq company--capf-cache
+              (list (current-buffer) (point) (buffer-chars-modified-tick) data))
+        data))))
+
+(defun company--capf-data-real ()
   (cl-letf* (((default-value 'completion-at-point-functions)
               ;; Ignore tags-completion-at-point-function because it subverts
               ;; company-etags in the default value of company-backends, where