"Stephen J. Turnbull" <turnbull(a)sk.tsukuba.ac.jp> writes:
> >>>>> "Hrvoje" == Hrvoje Niksic <hniksic(a)srce.hr> writes:
>
> Hrvoje> Jan Vroonhof <vroonhof(a)math.ethz.ch> writes:
>
> >> Why is font-lock using text-properties anyway? Isn't what it
> >> does much more naturally mapped on extents.
>
> Hrvoje> Not really (although it may look that way at the start).
> Hrvoje> The font-lock code wants to apply certain properties to
> Hrvoje> parts of the buffer, merging or breaking the extents as
> Hrvoje> needed. This is exactly what the text-properties are for.
>
> Could you be more specific? The documentation says something quite
> different: text-properties are for attaching properties to
> characters rather than intervals. That seems like exactly the
> _wrong_ thing to do with strings and comments, both of which should
> be locked up in an unbreakable (from the point of view of font-lock)
> extent once identified; the individual characters in them should
> never be considered "locally".
Well yes, but imagine merging two comments or strings, or splitting
one. In that case you have to break an extent in two parts, or merge
two adjacent extents. This is exactly what the text properties code
is supposed to do.
I think the code would be more complex if font-lock attempted to do
the merging/breaking by itself, but I might be wrong. It would
certainly be faster that way...
> OTOH, I don't see why splitting an extent or merging neighboring
> extents (which should be constant time, with relatively high
> overhead I suppose) should be more efficient than iterating over a
> (possibly lengthy) interval of characters (linear time but possibly
> lower overhead, depending on the implementation, although I find it
> hard to see why it would be necessarily much less than for extents).
I don't understand the question.
My point was that the "native" balanced-tree implementation of text
properties is bound to be faster than emulating them with extents.
Perhaps I am wrong on that one, too. I would certainly *like* to be
wrong on that one.
--
Hrvoje Niksic <hniksic(a)srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
We must all confront and destroy our own inner geek.