Skip to content

Commit ad1c2aa

Browse files
committed
Optimize el-get-read-all-recipe-names
This function is used to create completion candidates, so its slowness is quite noticable. The main cause of slowness was the reading of all the recipe files which can be avoided because the file name gives the recipe name. * el-get-recipes.el (el-get-all-recipe-file-names): new function. * el-get.el (el-get-read-all-recipe-names): use new function el-get-all-recipe-file-names instead of el-get-read-all-recipes to avoid having to read every recipe file.
1 parent 1b80536 commit ad1c2aa

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: el-get-recipes.el

+8
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ Used to avoid errors when exploring the path for recipes"
122122
(el-get-read-recipe-file filename)
123123
(error "El-get can not find a recipe for package \"%s\"" package))))
124124

125+
(defun el-get-all-recipe-file-names ()
126+
"Return the list of all file based recipe names.
127+
128+
The result may have duplicates."
129+
(loop for dir in (el-get-recipe-dirs)
130+
nconc (mapcar #'file-name-base
131+
(directory-files dir nil "^[^.].*\.\\(rcp\\|el\\)$"))))
132+
125133
(defun el-get-read-all-recipe-files ()
126134
"Return the list of all file based recipes, formated like `el-get-sources'.
127135

Diff for: el-get.el

+2-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@
221221
222222
This is useful to use for providing completion candidates for
223223
package names."
224-
(mapcar 'el-get-source-name (el-get-read-all-recipes)))
224+
(delete-dups (append (mapcar #'el-get-source-name el-get-sources)
225+
(el-get-all-recipe-file-names))))
225226

226227
(defun el-get-error-unless-package-p (package)
227228
"Raise an error if PACKAGE does not name a package that has a valid recipe."

0 commit comments

Comments
 (0)