• [gentoo-dev] [PATCH 2/3] texlive-module.eclass: Reduce number of execut

    From =?UTF-8?q?Ulrich=20M=C3=BCller?=@21:1/5 to All on Fri Jun 2 18:10:01 2023
    For texlive-latexextra-2021[doc], the number of "mv" commands is
    reduced from 12718 to 3130. Speedup is also by a factor of about 4,
    which saves another 4 seconds.

    Signed-off-by: Ulrich Müller <[email protected]>
    ---
    eclass/texlive-module.eclass | 12 ++++++++++--
    1 file changed, 10 insertions(+), 2 deletions(-)

    diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass
    index 99a90d91654f..a5c86b65cef0 100644
    --- a/eclass/texlive-module.eclass
    +++ b/eclass/texlive-module.eclass
    @@ -164,10 +164,18 @@ texlive-module_src_unpack() {
    sed -e 's/\/[^/]*$//' -e "s:^:${RELOC_TARGET}/:" "${T}/reloclist" |
    sort -u |
    xargs mkdir -p || die
    - local i
    + local i dir="" files=()
    while read i; do
    - mv "${i}" "${RELOC_TARGET}/${i%/*}" || die
    + if [[ ${RELOC_TARGET}/${i%/*} != "${dir}" ]]; then
    + # new dir, do the previous move
    + [[ -z ${dir} ]] || mv "${files[@]}" "${dir}" || die
    + dir="${RELOC_TARGET}/${i%/*}"
    + files=()
    + fi
    + # collect files with same destination dir
    + files+=( "${i}" )
    done < "${T}/reloclist"
    + mv "${files[@]}" "${dir}" || die
    }

    # @FUNCTION: texlive-module_add_format
    --
    2.40.1

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1