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

Patch for gui_w32.c

Expand Messages
  • Alexei Alexandrov
    Hi All! ... +++ D: projects 3rd-parties vim63 src gui_w32.c 2005-04-05 22:23:13.625000000 +0400 @@ -1774,7 +1774,7 @@ #ifdef FEAT_MBYTE static WCHAR
    Message 1 of 2 , Apr 5, 2005
    • 0 Attachment
      Hi All!

      I've been profiling Vim Win32 redrawer recently and noticed a bug in gui_w32.c source file, gui_mch_draw_string function. Here is the patch:

      --- D:\projects\3rd-parties\vim63.clean\src\gui_w32.c 2005-04-05 22:45:02.546875000 +0400
      +++ D:\projects\3rd-parties\vim63\src\gui_w32.c 2005-04-05 22:23:13.625000000 +0400
      @@ -1774,7 +1774,7 @@
      #ifdef FEAT_MBYTE
      static WCHAR *unicodebuf = NULL;
      static int *unicodepdy = NULL;
      - int unibuflen = 0;
      + static int unibuflen = 0;
      int n = 0;
      #endif
      HPEN hpen, old_pen;

      I'm not sure that I have the up-to-date sources, so the patch maybe not smooth to apply, but the idea of the fix should be clear. The unibuflen variable is used together with unicodebuf for caching the memory allocation requests. But since the author made it local instead of static we end up with allocating the memory constantly.

      Without the fix gui_mch_draw_string function spends about 7% of its time on alloc, and 16.3% - on vim_free. With the fix - it's close to zero.

      --
      Alexei Alexandrov
    • Bram Moolenaar
      ... Indeed, this was a mistake that easily goes unnoticed. I ll include the fix, thanks. -- hundred-and-one symptoms of being an internet addict: 75. You
      Message 2 of 2 , Apr 5, 2005
      • 0 Attachment
        Alexei Alexandrov wrote:

        > I've been profiling Vim Win32 redrawer recently and noticed a bug in
        > gui_w32.c source file, gui_mch_draw_string function. Here is the
        > patch:
        >
        > --- D:\projects\3rd-parties\vim63.clean\src\gui_w32.c 2005-04-05 22:45:02.546875000 +0400
        > +++ D:\projects\3rd-parties\vim63\src\gui_w32.c 2005-04-05 22:23:13.625000000 +0400
        > @@ -1774,7 +1774,7 @@
        > #ifdef FEAT_MBYTE
        > static WCHAR *unicodebuf = NULL;
        > static int *unicodepdy = NULL;
        > - int unibuflen = 0;
        > + static int unibuflen = 0;
        > int n = 0;
        > #endif
        > HPEN hpen, old_pen;
        >
        > I'm not sure that I have the up-to-date sources, so the patch maybe
        > not smooth to apply, but the idea of the fix should be clear. The
        > unibuflen variable is used together with unicodebuf for caching the
        > memory allocation requests. But since the author made it local instead
        > of static we end up with allocating the memory constantly.
        >
        > Without the fix gui_mch_draw_string function spends about 7% of its
        > time on alloc, and 16.3% - on vim_free. With the fix - it's close to
        > zero.

        Indeed, this was a mistake that easily goes unnoticed. I'll include the
        fix, thanks.

        --
        hundred-and-one symptoms of being an internet addict:
        75. You start wondering whether you could actually upgrade your brain
        with a Pentium Pro microprocessor 80. The upgrade works just fine.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
      Your message has been successfully submitted and would be delivered to recipients shortly.