Skip to content

Commit

Permalink
Use some clever caching to speed up init
Browse files Browse the repository at this point in the history
Partially addresses #9.
  • Loading branch information
raxod502 committed Jan 22, 2017
1 parent ac080a5 commit ded8359
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions straight.el
Original file line number Diff line number Diff line change
Expand Up @@ -338,20 +338,9 @@
(when after-init-time
(straight--save-build-cache)))

(defun straight--package-might-be-modified-p (recipe)
(straight--with-plist recipe
(package local-repo)
(or (not (file-exists-p (straight--file "build" package)))
(let ((mtime (nth 0 (gethash package straight--build-cache))))
(or (not mtime)
(with-temp-buffer
(let ((default-directory (straight--dir "repos" local-repo)))
(call-process
"find" nil '(t t) nil
"." "-name" ".git" "-prune" "-o" "-newermt" mtime "-print")
(> (buffer-size) 0))))))))

(defun straight--packages-might-be-modified-p ()
(defvar straight--cached-packages-might-be-modified-p :unknown)

(defun straight--cached-packages-might-be-modified-p ()
(let ((repos nil)
(args nil))
(maphash
Expand All @@ -374,6 +363,25 @@
(apply 'call-process "find" nil '(t t) nil args)
(> (buffer-size) 0)))))

(defun straight--package-might-be-modified-p (recipe)
(straight--with-plist recipe
(package local-repo)
(when (equal straight--cached-packages-might-be-modified-p
:unknown)
(setq straight--cached-packages-might-be-modified-p
(straight--cached-packages-might-be-modified-p)))
(when (or straight--cached-packages-might-be-modified-p
(not (gethash package straight--build-cache)))
(or (not (file-exists-p (straight--file "build" package)))
(let ((mtime (nth 0 (gethash package straight--build-cache))))
(or (not mtime)
(with-temp-buffer
(let ((default-directory (straight--dir "repos" local-repo)))
(call-process
"find" nil '(t t) nil
"." "-name" ".git" "-prune" "-o" "-newermt" mtime "-print")
(> (buffer-size) 0)))))))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Building packages

Expand Down

0 comments on commit ded8359

Please sign in to comment.