From 9d9afd8264cac86d57a64a0d119896ff23a07c7d Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 18 Apr 2018 15:40:52 -0500 Subject: [PATCH] Speed up ./configure completion by not running `./configure --help` Instead, attempt to extract the message that _would_ be displayed on execution of `./configure --help` by relying on some markers present in autoconf-generated configure files. As measured with 'hyperfine' on a laptop running in reduced frequency power savings mode, `fish -c "__fish_parse_configure ./configure"` runtime dropped from ~1.25s to ~0.8ms, which is inline with the previously observed ~350ms execution time for `./configure --help`. fish's own startup time is approximately 75ms before parsing begins. Still very slow, but much better. --- share/functions/__fish_parse_configure.fish | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/share/functions/__fish_parse_configure.fish b/share/functions/__fish_parse_configure.fish index 7fcb44dfe..aa8b94415 100644 --- a/share/functions/__fish_parse_configure.fish +++ b/share/functions/__fish_parse_configure.fish @@ -20,11 +20,15 @@ function __fish_parse_configure set -l next_line set -l line set -l buffer - eval $argv[1] --help 2>/dev/null | while test (string length -- "$next_line") -gt 0 || read -lL next_line + # eval $argv[1] --help 2>/dev/null | + # Just fish's `./configure --help` takes ~350ms to run, before parsing + # The following chain attempts to extract the help message: + cat $argv[1] | tr \n \u0e | sed -n 's/.*Report the --help message\(.*\?\)ac_status.*/\1/; s/ac_status.*//p' | tr \u0e \n | + while test "$next_line" != "" || read -lL next_line # In autoconfigure scripts, the first column wraps at 26 chars # echo next_line: $next_line # echo old_line: $line - if test (string length -- "$line") -eq 0 + if test "$line" = "" set line $next_line set next_line "" # mark it as consumed continue