perf(lib): minor optimizations
To reduce allocations in hot loops.
This commit is contained in:
parent
0d9e188b26
commit
6025e141aa
2 changed files with 25 additions and 19 deletions
|
@ -45,6 +45,7 @@ This is used by `file-exists-p!' and `project-file-exists-p!'."
|
|||
Ignores `nil' elements in SEGMENTS, and is intended as a fast compromise between
|
||||
`expand-file-name' (slow, but accurate), `file-name-concat' (fast, but
|
||||
inaccurate)."
|
||||
(declare (side-effect-free t))
|
||||
;; PERF: An empty `file-name-handler-alist' = faster `expand-file-name'.
|
||||
(let (file-name-handler-alist)
|
||||
(expand-file-name
|
||||
|
@ -69,7 +70,9 @@ If the glob ends in a slash, only returns matching directories."
|
|||
file-name-handler-alist
|
||||
(path (apply #'file-name-concat segments)))
|
||||
(if (string-suffix-p "/" path)
|
||||
(cl-delete-if-not #'file-directory-p (file-expand-wildcards (substring path 0 -1)))
|
||||
(cl-loop for file in (file-expand-wildcards (substring path 0 -1))
|
||||
if (file-directory-p file)
|
||||
collect file)
|
||||
(file-expand-wildcards path))))
|
||||
|
||||
;;;###autoload
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue