• [gentoo-dev] [PATCH] webapp.eclass: optimize webapp_serverowned() and i

    From Florian Schmaus@21:1/5 to All on Tue Oct 17 15:40:01 2023
    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_