Loading ...
Sorry, an error occurred while loading the content.

Re: function executable() is too slow on windows

Expand Messages
  • Yasuhiro MATSUMOTO
    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
    Message 1 of 7 , Jan 29, 2009
    • 0 Attachment
      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.jp@...> wrote:
      > Hmm. current directory was skipped with my patch.
      >
      > On Fri, Jan 30, 2009 at 3:17 PM, Yasuhiro MATSUMOTO <mattn.jp@...> 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.jp@...> 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
      -~----------~----~----~----~------~----~------~--~---
    • mattn
      Hi bram I got a report: exepath() return wrong value. So I updated this patch. https://gist.github.com/mattn/4d94e093bb777f79c444 When first argument is set as
      Message 2 of 7 , Aug 26, 2014
      • 0 Attachment
        Hi bram

        I got a report: exepath() return wrong value. So I updated this patch.

        https://gist.github.com/mattn/4d94e093bb777f79c444

        When first argument is set as NULL, SearchPath() works to search windows directory before PATH environment. So "C:\Windows\System32\counvert.exe" will be found even though PATH contains imagemagick directory at the first.

        Please check.
        - Yasuhiro Matsumoto

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Bram Moolenaar
        ... Thanks. Does this work well on all kinds of Windows systems? -- hundred-and-one symptoms of being an internet addict: 74. Your most erotic dreams are
        Message 3 of 7 , Aug 26, 2014
        • 0 Attachment
          Yasuhiro Matsumoto wrote:

          > Hi bram
          >
          > I got a report: exepath() return wrong value. So I updated this patch.
          >
          > https://gist.github.com/mattn/4d94e093bb777f79c444
          >
          > When first argument is set as NULL, SearchPath() works to search
          > windows directory before PATH environment. So
          > "C:\Windows\System32\counvert.exe" will be found even though PATH
          > contains imagemagick directory at the first.

          Thanks. Does this work well on all kinds of Windows systems?

          --
          hundred-and-one symptoms of being an internet addict:
          74. Your most erotic dreams are about cybersex

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ an exciting new programming language -- http://www.Zimbu.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          --
          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • mattn
          Ah, sorry. This is wrong. Because current directory must be contained in the search paths. system() or :! works with current directory. So ignore above
          Message 4 of 7 , Aug 26, 2014
          • 0 Attachment
            Ah, sorry.

            This is wrong. Because current directory must be contained in the search paths. system() or ":!" works with current directory. So ignore above reply.

            Please use patch older or look newer patch that k_takata modified for new version of vim.

            https://12985092515833507022.googlegroups.com/attach/7c3ae21f1b36721b/searchpath.patch?part=0.1&view=1&vt=ANaJVrHv5R2-Hk-rI2lEhEfEpSyuFMm9FK0e1TP5wg6MgB41sKqkMhGvLvBx2cI2GZH-sXFTlqNBxYGyUcT6SUZ3_KMWLBASyj-fVFBTTNFMvbkUlsuGIbc

            But some users seems to have a hard time to debug this. So please merge this.

            - Yasuhiro Matsumoto


            --
            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          Your message has been successfully submitted and would be delivered to recipients shortly.