ToonEx.Decode.Fast.Decoder (toon_ex v1.1.0)

Copy Markdown View Source

High-performance TOON decoder using pure binary pattern matching.

Performance Design

  1. No NimbleParsec – direct binary pattern matching replaces parser combinator overhead
  2. No regex in hot paths – binary pattern matching replaces all regex in the decode loop
  3. Line-by-line processing – tail-recursive accumulators with :lists.reverse/1
  4. Zero-copy slicingbinary_part/3 creates O(1) sub-binary references
  5. Erlang BIFs:binary.split/3, :binary.match/2, :maps.from_list/1
  6. Compile-time inlining@compile {:inline, [...]} for all hot functions
  7. Minimal allocations – tuple line info {content, indent, is_blank} instead of maps
  8. Fast-path splitting:binary.split/3 when no quotes present; quote-aware fallback
  9. Skip metadata – no MapSet/key_order tracking when expand_paths is off (default)

Summary

Functions

decode(input, opts \\ [])

@spec decode(
  binary(),
  keyword()
) :: {:ok, term()} | {:error, ToonEx.DecodeError.t()}

decode!(input, opts \\ [])

@spec decode!(
  binary(),
  keyword()
) :: term()