configure: use case instead of grep
Reimar Döffinger <[email protected]> Sat, 26 Feb 2022 20:46:53 +0100
| Newsgroups | gmane.comp.video.mplayer.devel |
|---|---|
| Message-ID | <[email protected]> |
Replace the grep with a case. This is about 20% faster on macOS and 3x faster in WSL1 on Windows. (sorry for not quite right email format, on the wrong computer ATM) _______________________________________________ MPlayer-dev-eng mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
configopt.diff
(application/octet-stream, 1.2 KB)
Index: configure
===================================================================
--- configure (revision 38335)
+++ configure (working copy)
@@ -8616,16 +8616,15 @@
mak_enable () {
list=$(echo $1 | toupper)
-item=$(echo $2 | toupper)
+item=" $(echo $2 | toupper) "
nprefix=$3;
suffix=$4
for part in $list; do
name="${nprefix}_${part}$suffix"
- if $(echo $item | grep -q -E "(^| )$part($| )"); then
- echo "$name = yes"
- else
- echo "!$name = yes"
- fi
+ case "$item" in
+ *" $part "*) echo "$name = yes" ;;
+ *) echo "!$name = yes" ;;
+ esac
done
}
@@ -9065,17 +9064,16 @@
ff_config_enable () {
list=$(echo $1 | toupper)
-item=$(echo $2 | toupper)
+item=" $(echo $2 | toupper) "
_nprefix=$4;
_defineprefix=$3;
_postfix=$5;
test -z "$_nprefix" && _nprefix='CONFIG'
for part in $list; do
- if $(echo $item | grep -q -E "(^| )$part($| )"); then
- echo "${_defineprefix}define ${_nprefix}_${part}${_postfix} 1"
- else
- echo "${_defineprefix}define ${_nprefix}_${part}${_postfix} 0"
- fi
+ case "$item" in
+ *" $part "*) echo "${_defineprefix}define ${_nprefix}_${part}${_postfix} 1" ;;
+ *) echo "${_defineprefix}define ${_nprefix}_${part}${_postfix} 0" ;;
+ esac
done
}