Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 2/3] completion: make: add a simpler parser
The make program does all the heavy lifting, there's no need to use a
full parser.
In the git build system I get an improvement of more than 3 times (from
3.68 to 1.07 seconds).
Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
Completion/Unix/Command/_make | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make
index 28c529a88..94747ae58 100644
--- a/Completion/Unix/Command/_make
+++ b/Completion/Unix/Command/_make
@@ -118,6 +118,24 @@ _make-parseMakefile () {
done
}
+_make-parseDataBase () {
+ local input var TAB=$'\t' IFS=
+
+ while read input
+ do
+ case "$input " in
+ ([[:alnum:]][[:alnum:]_]#[" "$TAB]#(\?|:|::|)=*)
+ var=${input%%[ $TAB]#(\?|:|::|)=*}
+ VARIABLES[$var]=1
+ ;;
+
+ ([[*?[:alnum:]$][^$TAB:=%]#:[^=]*)
+ TARGETS+=( ${input%%:*} )
+ ;;
+ esac
+ done
+}
+
_make() {
local prev="$words[CURRENT-1]" file expl tmp is_gnu incl match basedir nul=$'\0'
@@ -239,7 +257,7 @@ _make() {
if [[ $is_gnu == gnu ]]
then
if zstyle -t ":completion:${curcontext}:targets" call-command; then
- _make-parseMakefile < <(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .DEFAULT 2> /dev/null)
+ _make-parseDataBase < <(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .DEFAULT 2> /dev/null)
else
_make-parseMakefile < $file
fi
--
2.37.1.225.gfa48d685d2
Messages sorted by:
Reverse Date,
Date,
Thread,
Author