public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: //: fetch only one item per loop
@ 2024-03-27 20:58 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2024-03-27 20:58 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b7f5a33200a91ee76f5364280ad40bafedfab142

commit b7f5a33200a91ee76f5364280ad40bafedfab142
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Wed Mar 27 21:57:32 2024 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Wed Mar 27 21:57:32 2024 +0100

    Cygwin: //: fetch only one item per loop
    
    Simplify code in that it only fetches a single entry per
    IEnumShellItems::Next call.  For some reason this appears to
    be quicker most of the time.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler/netdrive.cc | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/winsup/cygwin/fhandler/netdrive.cc b/winsup/cygwin/fhandler/netdrive.cc
index 799ae9cb8e0b..90e5a22175d8 100644
--- a/winsup/cygwin/fhandler/netdrive.cc
+++ b/winsup/cygwin/fhandler/netdrive.cc
@@ -234,24 +234,20 @@ thread_netdrive_wsd (void *arg)
 
   do
     {
-      IShellItem *netitem[10] = { 0 };
+      IShellItem *netitem = NULL;
       LPWSTR item_name = NULL;
-      ULONG count;
 
-      wres = netitem_enum->Next (10, netitem, &count);
-      if (SUCCEEDED (wres) && count > 0)
+      wres = netitem_enum->Next (1, &netitem, NULL);
+      if (wres == S_OK)
 	{
-	  for (ULONG idx = 0; idx < count; ++idx)
+	  if (netitem->GetDisplayName (SIGDN_PARENTRELATIVEPARSING,
+					    &item_name) == S_OK)
 	    {
-	      if (netitem[idx]->GetDisplayName (SIGDN_PARENTRELATIVEPARSING,
-						&item_name) == S_OK)
-		{
-		  /* Skip "\\" on server names and downcase */
-		  DIR_cache.add (item_name + 2, true);
-		  CoTaskMemFree (item_name);
-		}
-	      netitem[idx]->Release ();
+	      /* Skip "\\" on server names and downcase */
+	      DIR_cache.add (item_name + 2, true);
+	      CoTaskMemFree (item_name);
 	    }
+	  netitem->Release ();
 	}
     }
   while (wres == S_OK);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-27 20:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-27 20:58 [newlib-cygwin/main] Cygwin: //: fetch only one item per loop Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).