[Top][All Lists]

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

Re: How is text properties stored?

From: Stefan Monnier
Subject: Re: How is text properties stored?
Date: Wed, 08 May 2019 20:58:23 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> overlays). That’s probably not the case since text property is supposed to
> be more efficient than overlays. So how does it work?

It's all in src/intervals.[ch].
It starts with:

    struct interval
      /* The first group of entries deal with the tree structure.  */
      ptrdiff_t total_length;       /* Length of myself and both children.  */
      ptrdiff_t position;               /* Cache of interval's character 
position.  */
                                    /* This field is valid in the final
                                       target interval returned by
                                       find_interval, next_interval,
                                       previous_interval and
                                       update_interval.  It cannot be
                                       depended upon in any intermediate
                                       intervals traversed by these
                                       functions, or any other
                                       interval. */
      struct interval *left;    /* Intervals which precede me.  */
      struct interval *right;   /* Intervals which succeed me.  */
      /* Parent in the tree, or the Lisp_Object containing this interval tree.  
        struct interval *interval;
        Lisp_Object obj;
      } up;
      bool_bf up_obj : 1;
      bool_bf gcmarkbit : 1;
      /* The remaining components are `properties' of the interval.
         The first four are duplicates for things which can be on the list,
         for purposes of speed.  */
      bool_bf write_protect : 1;            /* True means can't modify.  */
      bool_bf visible : 1;                  /* False means don't display.  */
      bool_bf front_sticky : 1;     /* True means text inserted just
                                       before this interval goes into it.  */
      bool_bf rear_sticky : 1;      /* Likewise for just after it.  */
      Lisp_Object plist;                    /* Other properties.  */

As you can see from the left/right fields, it's a binary tree.
And we try to keep it balanced (tho IIRC it's not quite always


reply via email to

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