emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NS port: How to debug excessive garbage collection?


From: Alex Gramiak
Subject: Re: NS port: How to debug excessive garbage collection?
Date: Sun, 14 Apr 2019 21:44:41 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Keith David Bershatsky <address@hidden> writes:

> Thank you, Alex ... I like the idea of not using a Lisp_Object to store the
> various window caches of fake cursors, as this would entirely eliminate the
> garbage collection issues. Inasmuch as this would be my first usage of an 
> array
> in the world of programming, some guidance regarding the best way to 
> initialize
> the array (window cache) would be greatly appreciated.

Sorry, I shouldn't have said to use a C array in this case. A struct
would be better in this case due to the different types involved.

> I saw three types of arrays: an array matching an exact size known in advance;
> an array that is defined with a specified MAX_ROW / MAX_COL (some rows/columns
> may never be used); and, an array using dynamic allocation with malloc, 
> realloc
> and free.

Right.

> Each window cache should be able to handle up to 250 fake cursors.

Is 250 an arbitrary limit?

> How do you recommend that the array for each window cache be initialized?
>
> 1.  int x
> 2.  int fx
> 3.  int y
> 4.  int fy
> 5.  int hpos
> 6.  int vpos
> 7.  int wd
> 8.  int h
> 9.  int cursor_type
> 10. int cursor_width
> 11. double foreground_red
> 12. double foreground_green
> 13. double foreground_blue
> 14. double background_red
> 15. double background_green
> 16. double background_blue
> 17. bool active_p
> 18. int glyph_flavor

To change it to a struct (with a helper struct):

  struct RGB
  {
    double red;
    double green;
    double blue;
  };

  struct multiple_cursor_cache
  {
    int x;
    int fx;
    int y;
    int fy;
    int hpos;
    int vpos;
    int wd;
    int h;
    int cursor_type;
    int cursor_width;
    struct RGB foreground;
    struct RGB background;
    bool active_p;
    int glyph_flavor;
  };

Then you have:

  struct multiple_cursor_cache mc_cache;

and to set elements:

  w->mc_cache.x = x;
  w->mc_cache.foreground.red = red;

To set all elements to zero, one does:

  memset (&variable, 0, sizeof (variable));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]