From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fergus Henderson To: "Larry Hall (RFK Partners, Inc)" Cc: hcobb@telegenisys.com, cygwin@sourceware.cygnus.com Subject: Re: Time taken for ls -la --color=yes Date: Wed, 31 Mar 1999 19:45:00 -0000 Message-ID: <19990309062922.64739@mundook.cs.mu.OZ.AU> References: <36E40422.157007C1@atos-group.com> <199903081638.LAA11084@y11a165.neo.rr.com> <199903081826.NAA16303@acestes-fe0.ultra.net> <3.0.5.32.19990308133351.009bb950@pop.ma.ultranet.com> X-SW-Source: 1999-03n/msg00251.html Message-ID: <19990331194500.IPxu8TrjZxvAlweX-ic7lrReQvmQcZOt04T3TdSPNbo@z> 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: < http://www.cs.mu.oz.au/~fjh > | of excellence is a lethal habit" PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp. -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe@sourceware.cygnus.com