pub struct LineCache<L: LanguageLexer> { /* private fields */ }Expand description
The incremental re-lex cache over any LanguageLexer. The LineState
fixpoint made operational: re-lexing halts at the first line whose entry
state and bytes both match the cache, so an edit costs
O(changed lines + lines until the carried state re-converges), not
O(document).
Zero-dependency by design (hikari-core’s invariant): the content compare is
std str equality and the cache stores the line bytes. A hikari-* sibling
may swap the Box<str> for a BLAKE3 row hash to drop the O(document) memory
— that is a strictly-internal change behind this same object-safe trait.
Implementations§
Trait Implementations§
Source§impl<L: LanguageLexer> IncrementalHighlighter for LineCache<L>
impl<L: LanguageLexer> IncrementalHighlighter for LineCache<L>
Source§fn highlight(&mut self, text: &str) -> Vec<HighlightSpan>
fn highlight(&mut self, text: &str) -> Vec<HighlightSpan>
Re-highlight
text, reusing cached per-line spans where the document
is unchanged. &mut self because the cache advances.Source§fn last_relexed(&self) -> usize
fn last_relexed(&self) -> usize
How many lines the most recent
highlight call
actually re-lexed — 0 on a fully-cached (idle re-render) call. The
seal’s idle-work witness: an unchanged document re-lexes nothing.Auto Trait Implementations§
impl<L> Freeze for LineCache<L>where
L: Freeze,
impl<L> RefUnwindSafe for LineCache<L>
impl<L> Send for LineCache<L>
impl<L> Sync for LineCache<L>
impl<L> Unpin for LineCache<L>
impl<L> UnsafeUnpin for LineCache<L>where
L: UnsafeUnpin,
impl<L> UnwindSafe for LineCache<L>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more