I wrote new patch. however it took delay time nearly same as no patched. X-(

BTW)
I have which.exe command line program which is downloaded on
http://gnuwin32.sf.net.
It is better faster than executable(). maybe it does not use SearchPath() API.

On Fri, Jan 30, 2009 at 3:43 PM, Yasuhiro MATSUMOTO <mattn...@gmail.com> wrote:
> Hmm. current directory was skipped with my patch.
>
> On Fri, Jan 30, 2009 at 3:17 PM, Yasuhiro MATSUMOTO <mattn...@gmail.com> 
> wrote:
>> oops.
>>
>> ---------------------
>> function executable() is too slow on windows. it seems that using
>> SearchPath() API.
>> SearchPath() tries following sequence if lpPath was set NULL.
>> ---------------------
>>
>> On Fri, Jan 30, 2009 at 3:12 PM, Yasuhiro MATSUMOTO <mattn...@gmail.com> 
>> wrote:
>>> Hi, bram and all.
>>>
>>> function executable() is too slow on windows. it seems that using
>>> SearchPath() API.
>>> SearchPath() tries following sequence if lp.
>>>
>>> 1. Location at executable.
>>> 2. Current directory
>>> 3. Windows System Direction which can get with GetSystemDirectory().
>>> 4. Windows Directory.
>>> 5. Specified as PATH environment variable.
>>>
>>> * see remarks at
>>> http://msdn.microsoft.com/en-us/library/aa365527%28VS.85%29.aspx
>>>
>>> I guess that No3, No4, No5 is duplicated and I guess that No5 include
>>> No3 and No4.
>>> For size, I tried following patch and function executable() had few
>>> speed-up. :-)
>>> If i use netrw.vim then it took 3 seconds for getting password prompt
>>> from type ':e ftp://xxx'.
>>> But it took 1.5 seconds for them with following patch.
>>>
>>> Thanks.
>>>
>>> Index: src/os_win32.c
>>> ===================================================================
>>> --- src/os_win32.c      (revision 1326)
>>> +++ src/os_win32.c      (working copy)
>>> @@ -1594,7 +1594,7 @@
>>>
>>>        if (p != NULL)
>>>        {
>>> -           n = (long)SearchPathW(NULL, p, NULL, _MAX_PATH, fnamew, &dumw);
>>> +           n = (long)SearchPathW(_wgetenv(L"PATH"), p, NULL, _MAX_PATH,
>>> fnamew, &dumw);
>>>            vim_free(p);
>>>            if (n > 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
>>>            {
>>> @@ -1608,7 +1608,7 @@
>>>        }
>>>     }
>>>  #endif
>>> -    if (SearchPath(NULL, name, NULL, _MAX_PATH, fname, &dum) == 0)
>>> +    if (SearchPath(getenv("PATH"), name, NULL, _MAX_PATH, fname, &dum) == 
>>> 0)
>>>        return FALSE;
>>>     if (mch_isdir(fname))
>>>        return FALSE;
>>>
>>>
>>> --
>>> - Yasuhiro Matsumoto
>>>
>>
>>
>>
>> --
>> - Yasuhiro Matsumoto
>>
>
>
>
> --
> - Yasuhiro Matsumoto
>


Index: src/os_win32.c
===================================================================
--- src/os_win32.c      (revision 1341)
+++ src/os_win32.c      (working copy)
@@ -1583,6 +1583,8 @@
 {
     char       *dum;
     char       fname[_MAX_PATH];
+    char       *path, *newpath;
+    long       n;

 #ifdef FEAT_MBYTE
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
@@ -1590,11 +1592,18 @@
        WCHAR   *p = enc_to_utf16(name, NULL);
        WCHAR   fnamew[_MAX_PATH];
        WCHAR   *dumw;
-       long    n;
+       WCHAR   *wpath, *wnewpath;

        if (p != NULL)
        {
-           n = (long)SearchPathW(NULL, p, NULL, _MAX_PATH, fnamew, &dumw);
+           wpath = _wgetenv(L"PATH");
+           wnewpath = (WCHAR*)alloc((unsigned)(wcslen(wpath) + 4) * 
sizeof(WCHAR));
+           if (wnewpath == NULL)
+               return FALSE;
+           wcscpy(wnewpath, L";.;");
+           wcscat(wnewpath, wpath);
+           n = (long)SearchPathW(wnewpath, p, NULL, _MAX_PATH, fnamew, &dumw);
+           vim_free(wnewpath);
            vim_free(p);
            if (n > 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
            {
@@ -1608,8 +1617,17 @@
        }
     }
 #endif
-    if (SearchPath(NULL, name, NULL, _MAX_PATH, fname, &dum) == 0)
+
+    path = getenv("PATH");
+    newpath = (char*)alloc((unsigned)(STRLEN(path) + 4));
+    if (newpath == NULL)
        return FALSE;
+    STRCPY(newpath, ";.;");
+    STRCAT(newpath, path);
+    n = (long)SearchPath(newpath, name, NULL, _MAX_PATH, fname, &dum);
+    vim_free(newpath);
+    if (n == 0)
+       return FALSE;
     if (mch_isdir(fname))
        return FALSE;
     return TRUE;

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui