summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Schmaus <flow@gentoo.org>2023-10-17 14:38:00 +0200
committerFlorian Schmaus <flow@gentoo.org>2023-10-18 14:10:37 +0200
commit83b08b7d9434e5829ddaee08562790a2d939fa99 (patch)
tree1058a9abaebccf3ccb1fc74c6e6d7379506cf0cd
parentdev-python/QtPy: add USE=sensors and USE=speech (diff)
downloadgentoo-83b08b7d9434e5829ddaee08562790a2d939fa99.tar.gz
gentoo-83b08b7d9434e5829ddaee08562790a2d939fa99.tar.bz2
gentoo-83b08b7d9434e5829ddaee08562790a2d939fa99.zip
webapp.eclass: optimize webapp_serverowned() and inline webapp_strip_*()
Some ebuilds invoke webapp_serverowned() with -R, causing the eclass to iterate over a large set of files. Within the iteration's body the eclass forks multiple times to invoke the webapp_strip, which is very inefficient and causes a huge slowdown. This optimizes webapp_serverowned() by replacing the iteration and call to the "strip" functions with a single equivalent invocation of find to iterates all the files. Furthermore, all remaining invocations of webapp_strip_*() are inlined. Closes: https://bugs.gentoo.org/781860 Signed-off-by: Florian Schmaus <flow@gentoo.org>
-rw-r--r--eclass/webapp.eclass40
1 files changed, 16 insertions, 24 deletions
diff --git a/eclass/webapp.eclass b/eclass/webapp.eclass
index 8bd8e2aef03e..5b091c84851f 100644
--- a/eclass/webapp.eclass
+++ b/eclass/webapp.eclass
@@ -96,21 +96,6 @@ webapp_check_installedat() {
${WEBAPP_CONFIG} --show-installed -h localhost -d "${INSTALL_DIR}" 2> /dev/null
}
-webapp_strip_appdir() {
- debug-print-function $FUNCNAME $*
- echo "${1#${MY_APPDIR}/}"
-}
-
-webapp_strip_d() {
- debug-print-function $FUNCNAME $*
- echo "${1#${D}}"
-}
-
-webapp_strip_cwd() {
- debug-print-function $FUNCNAME $*
- echo "${1/#.\///}"
-}
-
webapp_getinstalltype() {
debug-print-function $FUNCNAME $*
@@ -195,8 +180,11 @@ webapp_configfile() {
for m in "$@"; do
webapp_checkfileexists "${m}" "${D}"
- local my_file="$(webapp_strip_appdir "${m}")"
- my_file="$(webapp_strip_cwd "${my_file}")"
+ local my_file
+ # Strip appdir
+ my_file="${m#${MY_APPDIR}/}"
+ # Strip cwd
+ my_file="${my_file/#.\///}"
elog "(config) ${my_file}"
echo "${my_file}" >> "${D}/${WA_CONFIGLIST}"
@@ -249,8 +237,11 @@ _webapp_serverowned() {
debug-print-function $FUNCNAME $*
webapp_checkfileexists "${1}" "${D}"
- local my_file="$(webapp_strip_appdir "${1}")"
- my_file="$(webapp_strip_cwd "${my_file}")"
+ local my_file
+ # Strip appdir
+ my_file="${1#${MY_APPDIR}/}"
+ # Strip cwd
+ my_file="${my_file/#.\///}"
echo "${my_file}" >> "${D}/${WA_SOLIST}"
}
@@ -264,14 +255,15 @@ _webapp_serverowned() {
webapp_serverowned() {
debug-print-function $FUNCNAME $*
- local a m
+ local m
if [[ "${1}" == "-R" ]]; then
shift
for m in "$@"; do
- find "${D}${m}" | while read a; do
- a=$(webapp_strip_d "${a}")
- _webapp_serverowned "${a}"
- done
+ pushd "${D}${MY_APPDIR}" > /dev/null || die
+ # Strip appdir
+ m="${m#${MY_APPDIR}/}"
+ find "${m}" >> "${D}/${WA_SOLIST}" || die
+ popd > /dev/null || die
done
else
for m in "$@"; do