From: Alejandro Colomar Date: Sun, 14 Nov 2021 13:54:24 +0000 (+0100) Subject: bash_aliases: grep_*(): Optimize X-Git-Tag: man-pages-5.19-rc1~833 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2823cdab8888171e4fc8523f5d08f080487009cc;p=thirdparty%2Fman-pages.git bash_aliases: grep_*(): Optimize Using grep first to reduce the files on which pcregrep is run optimizes considerably the performance of these functions. If a file doesn't contain the name of a function, which can easily be checked with grep, it won't possibly contain the function prototype or definition, which is much slower to search, since it implies multiline pcregrep search. Signed-off-by: Alejandro Colomar --- diff --git a/scripts/bash_aliases b/scripts/bash_aliases index be0672595a..e9f63b1519 100644 --- a/scripts/bash_aliases +++ b/scripts/bash_aliases @@ -52,12 +52,14 @@ function grep_syscall() find * -type f \ |grep '\.c$' \ + |xargs grep -l "${1}" \ |sort \ |xargs pcregrep -Mn "(?s)^\w*SYSCALL_DEFINE.\(${1},.*?\)" \ |sed -E 's/^[^:]+:[0-9]+:/&\n/'; find * -type f \ |grep '\.[ch]$' \ + |xargs grep -l "${1}" \ |sort \ |xargs pcregrep -Mn "(?s)^asmlinkage\s+[\w\s]+\**sys_${1}\s*\(.*?\)" \ |sed -E 's/^[^:]+:[0-9]+:/&\n/'; @@ -77,6 +79,7 @@ function grep_syscall_def() find * -type f \ |grep '\.c$' \ + |xargs grep -l "${1}" \ |sort \ |xargs pcregrep -Mn "(?s)^\w*SYSCALL_DEFINE.\(${1},.*?^}" \ |sed -E 's/^[^:]+:[0-9]+:/&\n/'; @@ -216,6 +219,7 @@ function grep_glibc_prototype() find * -type f \ |grep '\.h$' \ + |xargs grep -l "${1}" \ |sort \ |xargs pcregrep -Mn \ "(?s)^[\w[][\w\s(,)[:\]]+\s+\**${1}\s*\([\w\s(,)[\]*]+?(...)?\)[\w\s(,)[:\]]*;" \