From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id DF4AE15807A for ; Sat, 07 Jun 2025 22:55:26 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id CAE95342FE5 for ; Sat, 07 Jun 2025 22:55:26 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 322321104BD; Sat, 07 Jun 2025 22:54:50 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 230891104BC for ; Sat, 07 Jun 2025 22:54:50 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D0597343113 for ; Sat, 07 Jun 2025 22:54:49 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 36697290D for ; Sat, 07 Jun 2025 22:54:47 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1749336856.ddbd213e3ad2d1f340c5cd86b102cc1788b836b6.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/ecompress X-VCS-Directories: bin/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: ddbd213e3ad2d1f340c5cd86b102cc1788b836b6 X-VCS-Branch: master Date: Sat, 07 Jun 2025 22:54:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 7b94e19b-7779-4dc1-a4a9-97bef54bfb8b X-Archives-Hash: bd1002dd4974912beff36754813073bf commit: ddbd213e3ad2d1f340c5cd86b102cc1788b836b6 Author: Kerin Millar plushkava net> AuthorDate: Sat Jun 7 18:37:11 2025 +0000 Commit: Sam James gentoo org> CommitDate: Sat Jun 7 22:54:16 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ddbd213e ecompress: accelerate fix_symlinks() by having find(1) resolve targets The GNU implementation of the find(1) utility offers some powerful primaries. Enhance the performance of the fix_symlinks() function by taking advantage of them. The exact manner in which this is accomplished is described herewith. Use the -xtype l primary so as not to waste any time processing non-dangling symlinks. The shell is duly relieved of the need to test for the existence of the link's target. Use the -printf primary so as to print NUL-terminated pairs, where the first item is the path of the symlink, and the second item its target. Not only does this avoid an expensive invocation of readlink(1) for each iteration of the loop but it also guarantees that any possible target will be processed correctly. Hitherto, this had not been the case, for the following reasons. - the character can legally be present within a pathname - readlink(1) arbitrarily produces a trailing character - command substitutions strip all trailing characters Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> bin/ecompress | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/ecompress b/bin/ecompress index 490fd8d345..b6063d87ce 100755 --- a/bin/ecompress +++ b/bin/ecompress @@ -138,11 +138,9 @@ fix_symlinks() { # levels of indirection (see bug #470916). while true ; do something_changed=0 - while IFS= read -rd '' link; do - [[ -e ${link} ]] && continue - - target1=$(readlink -- "${link}") + while IFS= read -rd '' link && IFS= read -rd '' target1; do target2=${target1}${PORTAGE_COMPRESS_SUFFIX} + if [[ ${target2} == /* ]]; then if [[ ! -f ${D%/}${target2} ]]; then continue @@ -155,7 +153,7 @@ fix_symlinks() { rm -f -- "${link}" \ && ln -snf -- "${target2}" "${link}${PORTAGE_COMPRESS_SUFFIX}" \ || return - done < <(printf '%s\0' "${ED}" | find0 -type l -print0) + done < <(printf '%s\0' "${ED}" | find0 -type l -xtype l -printf '%p\0%l\0') # Check whether the invocation of find(1) succeeded. wait "$!" || return