On 05/16/2011 12:57 PM, Jim Meyering wrote:
> Paul Eggert wrote:
>> On 05/16/11 07:44, Pádraig Brady wrote:
>>> I tested your ls ordering trick on linux, solaris 10 and freebsd and it 
>>> works.
>>> Please push.
>>
>> Thanks, done.
> 
> Thanks.  I appreciate the added comments, too ;-)
> 
> What do you think of this addition?
> It may be more efficient to invoke one subshell rather than two,
> even though the new subshell includes an additional pipe to sed.
> For the record, I don't really care either way, since even for coreutils,
> saving 1000 subshells (one per file from gnulib) is probably a
> negligible gain in performance, overall.

Anything that shaves 1000 processes is worthwhile for cygwin.  However,

> @@ -677,9 +677,8 @@ symlink_to_dir()
>        # so that broken tools aren't confused into skipping needed builds.  
> See
>        # <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
>        test -h "$dst" &&
> -      src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
> -      dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
> -      test "$src_i" = "$dst_i" &&
> +      inums=`ls -1diL "$src" "$dst" 2>/dev/null|sed 's/ .*//'` && set $inums 
> &&

Two subshells with no pipe vs. one subshell with a pipe produces the
same amount of fork/exec calls under bash, so you aren't saving
processes in this case.  On it's own merits, I have no strong opinions
about keeping or dropping this patch.

But you gave me an idea that _does_ speed up cygwin:

inums=`ls -1diL "$src" "$dst" 2>/dev/null`
inum1=${inums%%[!0-9]*}
inums=${inums#*
}
inum2=${inums%%[!0-9]*}
test "$inum1" = "$inum2"

which computes the same with only one child process, by avoiding both a
second ls and a pipeline.  On the other hand, it only works with POSIX
shells (Solaris /bin/sh doesn't understand the XSI notion of %% and ##).

-- 
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to