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

39502Patch for gui_w32.c

Expand Messages
  • Alexei Alexandrov
    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;
      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
    • Show all 2 messages in this topic