Raxol.Terminal.ANSI.CachedParser (Raxol v2.0.1)

View Source

Optimized ANSI parser with caching for common sequences.

Phase 1 optimization to reduce memory overhead and improve performance for frequently used escape sequences.

Summary

Functions

Benchmark comparison between cached and original parser.

Get statistics about cache coverage.

Parses ANSI escape sequences with caching optimization.

Types

parsed_token()

@type parsed_token() ::
  {:text, binary()}
  | {:csi, binary(), binary()}
  | {:osc, binary()}
  | {:dcs, binary()}
  | {:escape, binary()}

Functions

benchmark_comparison(input, iterations \\ 10000)

Benchmark comparison between cached and original parser.

cache_stats()

Get statistics about cache coverage.

parse(input)

@spec parse(binary()) :: [parsed_token()]

Parses ANSI escape sequences with caching optimization.

First checks if the input exactly matches a common cached sequence, then falls back to full parsing for complex inputs.