public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Florian Schmaus <flow@gentoo.org>
To: gentoo-dev@lists.gentoo.org, web-apps@gentoo.org
Cc: Florian Schmaus <flow@gentoo.org>
Subject: [gentoo-dev] [PATCH] webapp.eclass: optimize webapp_serverowned() and inlining webapp_strip_*()
Date: Tue, 17 Oct 2023 15:34:46 +0200	[thread overview]
Message-ID: <20231017133446.56240-1-flow@gentoo.org> (raw)

Some ebuilds invoke webapp_serverowned with -r, causing the eclass to
iterate over a large set of files. Within the iteration body, the eclass
forks multiple times to invoke the webapp_strip.

This optimizes webapp_serverowned() by replacing the call to the "strip"
functions with an equivalent invocation of find that iterates over 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>
---
 eclass/webapp.eclass | 40 ++++++++++++++++------------------------
 1 file 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
-- 
2.41.0



                 reply	other threads:[~2023-10-17 13:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231017133446.56240-1-flow@gentoo.org \
    --to=flow@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    --cc=web-apps@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox