1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Prefer to run find and grep in parallel in rgrep (bug#71094)

* lisp/progmodes/grep.el (grep-compute-defaults): Prefer `gnu' for
grep-find-use-xargs over `exec-plus', but not on Windows.  (bug#71094)
This commit is contained in:
Spencer Baugh 2024-07-03 15:39:23 +02:00 committed by Andrea Corallo
parent 65bd41d1cf
commit f7725d85f3

View file

@ -827,15 +827,23 @@ The value depends on `grep-command', `grep-template',
(unless grep-find-use-xargs
(setq grep-find-use-xargs
(cond
((grep-probe find-program
`(nil nil nil ,(null-device) "-exec" "echo"
"{}" "+"))
'exec-plus)
;; For performance, we want:
;; A. Run grep on batches of files (instead of one grep per file)
;; B. If the directory is large and we need multiple batches,
;; run find in parallel with a running grep.
;; "find | xargs grep" gives both A and B
((and
(not (eq system-type 'windows-nt))
(grep-probe
find-program `(nil nil nil ,(null-device) "-print0"))
(grep-probe xargs-program '(nil nil nil "-0" "echo")))
'gnu)
;; "find -exec {} +" gives A but not B
((grep-probe find-program
`(nil nil nil ,(null-device) "-exec" "echo"
"{}" "+"))
'exec-plus)
;; "find -exec {} ;" gives neither A nor B.
(t
'exec))))
(unless grep-find-command