diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-14 14:54:24 +0100 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-14 14:54:26 +0100 |
commit | 2823cdab8888171e4fc8523f5d08f080487009cc (patch) | |
tree | 602d011a758026ba0ffa7d9f6abbe6e1630f441a /scripts | |
parent | 6ff6f43d68164f99a8c3fb66f4525d145571310c (diff) | |
download | man-pages-2823cdab8888171e4fc8523f5d08f080487009cc.tar.gz |
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 <alx.manpages@gmail.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/bash_aliases | 4 |
1 files changed, 4 insertions, 0 deletions
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(,)[:\]]*;" \ |