Optimization for FindFile* (resend)

Robert Shearman rob at codeweavers.com
Fri Aug 20 13:45:58 CDT 2004


Changelog:
Handle case of mask containing no wildcards so that it is possible to 
avoid searching through hundreds of directory entries.

-------------- next part --------------
Index: wine/dlls/ntdll/directory.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/directory.c,v
retrieving revision 1.16
diff -u -r1.16 directory.c
--- wine/dlls/ntdll/directory.c	7 Jul 2004 00:47:10 -0000	1.16
+++ wine/dlls/ntdll/directory.c	21 Jul 2004 17:05:21 -0000
@@ -680,6 +680,25 @@
 
     io->Information = 0;
 
+    /* case of no wildcards in mask -> no need to search directory
+     * assuming the case of the mask is the same as the filename */
+    if (!memchrW( mask->Buffer, '*', mask->Length/sizeof(WCHAR) ) &&
+        !memchrW( mask->Buffer, '?', mask->Length/sizeof(WCHAR) ) &&
+        fchdir( fd ) != -1)
+    {
+        char name[MAX_DIR_ENTRY_LEN];
+        int name_len = ntdll_wcstoumbs( 0, mask->Buffer,
+            mask->Length/sizeof(WCHAR), name, sizeof(name)-sizeof(char), NULL, NULL );
+        name[name_len] = '\0';
+        info = append_entry( buffer, &io->Information, length,
+            name, NULL, mask );
+        if (info)
+        {
+            wine_server_release_fd( handle, fd );
+            return STATUS_SUCCESS;
+        }
+    }
+
     RtlEnterCriticalSection( &dir_section );
 
     if (show_dir_symlinks == -1) init_options();


More information about the wine-patches mailing list