Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-ID: <19990309062922.64739@mundook.cs.mu.OZ.AU> Date: Tue, 9 Mar 1999 06:29:22 +1100 From: Fergus Henderson To: "Larry Hall (RFK Partners, Inc)" Cc: hcobb AT telegenisys DOT com, cygwin AT sourceware DOT cygnus DOT com Subject: Re: Time taken for ls -la --color=yes References: <36E40422 DOT 157007C1 AT atos-group DOT com> <199903081638 DOT LAA11084 AT y11a165 DOT neo DOT rr DOT com> <36E40422 DOT 157007C1 AT atos-group DOT com> <199903081826 DOT NAA16303 AT acestes-fe0 DOT ultra DOT net> <3 DOT 0 DOT 5 DOT 32 DOT 19990308133351 DOT 009bb950 AT pop DOT ma DOT ultranet DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.88 In-Reply-To: <3.0.5.32.19990308133351.009bb950@pop.ma.ultranet.com>; from Larry Hall (RFK Partners, Inc) on Mon, Mar 08, 1999 at 01:33:51PM -0500 On 08-Mar-1999, Larry Hall (RFK Partners, Inc) wrote: > At 01:26 PM 3/8/99 -0500, Henry J. Cobb wrote: > >Doesn't LS take a lot of time to count the entries in every subdirectory it > >encounters (even when it never lists them) just in order to fill out the > >stat structures it then throws away? Yes, I believe so. Well, it's actually the stat() DLL call that is taking the time, rather than the code in the `ls' executable itself. There's no simple way for the stat() DLL call to figure out whether the caller will use the `st_nlinks' field in the stat struct. So it has to assume that it will be used. And implementing Unix semantics for the st_nlinks field when stat() is called on a directory requires counting the number of subdirectories in that directory. I suppose ls could be patched to use something other than stat(). The ideal solution would be to patch the compiler to automatically figure out whether the caller was using the st_nlinks field, and if not, to automatically substitute say `__cheap_stat()' instead of `stat()'. However, this is not very feasible in a language like C... -- Fergus Henderson | "I have always known that the pursuit WWW: | of excellence is a lethal habit" PGP: finger fjh AT 128 DOT 250 DOT 37 DOT 3 | -- the last words of T. S. Garp. -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com