> Please note that the parsing process is inherently linear, since we're > in a context-dependent grammar. Thus, there's not much to do about the > parsing algorithm. > > However, the cache is always up-to-date. So, we are not bound to start > again from headline if we can find a cached element between it and the > point. The closer, the better. > > I think there's room for improvement in this area. An idea could be to > start `org-element-at-point' with an opportunistic search. Before going > back to the headline, we could, indeed, `search-backward' on > `org-element-paragraph-start' a couple of times and check if location > found is already cached. This would work well when parsing successively > elements in the same section or when editing the current paragraph.
I implemented it. `org-element-at-point' runs in a mean constant time now (worst case is still linear, though). -- Nicolas Goaziou