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 <u...@gentoo.org>
---
 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


Reply via email to