https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b7f5a33200a91ee76f5364280ad40bafedfab142
commit b7f5a33200a91ee76f5364280ad40bafedfab142 Author: Corinna Vinschen <[email protected]> AuthorDate: Wed Mar 27 21:57:32 2024 +0100 Commit: Corinna Vinschen <[email protected]> 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 <[email protected]> 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);
