CVS: winex/files dos_fs.c,1.33,1.34
[email protected] 31 Jul 2007 17:43:38 -0000
| Newsgroups | gmane.comp.emulators.winex.cvs |
|---|---|
| Message-ID | <[email protected]> |
Subject: winex/files dos_fs.c,1.33,1.34Update of /var/lib/cvsd/cvsroot/winex/files
In directory agravaine:/tmp/cvs-serv22779/files
Modified Files:
dos_fs.c
Log Message:
- optimize DOSFS_FindUnixName for the common case that the target exists and full names/paths are given
Index: dos_fs.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/files/dos_fs.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- dos_fs.c 28 Mar 2007 21:05:48 -0000 1.33
+++ dos_fs.c 31 Jul 2007 17:43:36 -0000 1.34
@@ -608,6 +608,8 @@
LPCSTR long_name, short_name;
char dos_name[12], tmp_buf[13];
BOOL ret;
+ char *full_path, *cur_char;
+ BY_HANDLE_FILE_INFORMATION info;
const char *p = strchr( name, '/' );
int len = p ? (int)(p - name) : strlen(name);
@@ -616,10 +618,41 @@
while (len > 1 && (name[len-1] == '.' || name[len-1] == ' ')) len--;
if (long_len < len + 1) return FALSE;
- TRACE("%s,%s\n", path, name );
+ TRACE ("%s,%s\n", path, name);
if (!DOSFS_ToDosFCBFormat( name, dos_name )) dos_name[0] = '\0';
+ /* As an optimization - try the path and the first part of the
+ name, and see if that combination exists. If so, we're
+ done. From examining traces, this is the case a large
+ percentage of the time */
+ full_path = HeapAlloc (GetProcessHeap (), 0,
+ strlen (path) + len + 2);
+ if (!full_path)
+ {
+ ERR ("Couldn't allocate full_path - OOM!\n");
+ return FALSE;
+ }
+
+ strcpy (full_path, path);
+ cur_char = full_path + strlen (full_path);
+ *cur_char++ = '/';
+ strncpy (cur_char, name, len);
+ cur_char[len] = '\0';
+ if (FILE_Stat (full_path, &info))
+ {
+ if (long_buf)
+ strcpy (long_buf, cur_char);
+ if (short_buf)
+ DOSFS_Hash (cur_char, short_buf, FALSE, ignore_case);
+ TRACE("(%s,%s) -> %s (%s)\n",
+ path, name, cur_char, short_buf ? short_buf : "***");
+
+ HeapFree (GetProcessHeap (), 0, full_path);
+ return TRUE;
+ }
+ HeapFree (GetProcessHeap (), 0, full_path);
+
if (!(dir = DOSFS_OpenDir( path )))
{
WARN("(%s,%s): can't open dir: %s\n",