Localize.Collation.FastLatin (Localize v0.38.0)

Copy Markdown View Source

Fast lookup table for Basic Latin and Latin Extended-A codepoints.

Provides O(1) collation element lookup for codepoints U+0000..U+017F by pre-computing a tuple indexed by codepoint value. This bypasses the full contraction-checking path in Localize.Collation.Table for the most commonly encountered characters.

Codepoints that are contraction starters (e.g., L and l for Catalan l·l) or combining marks (CCC > 0) are excluded from the fast table and fall back to the normal lookup path.

Summary

Functions

Build the fast Latin lookup table from the loaded collation table.

Look up collation elements for a Latin codepoint.

Functions

build()

@spec build() :: :ok

Build the fast Latin lookup table from the loaded collation table.

Reads the collation table and contraction starters from :persistent_term, and constructs a tuple of @latin_limit entries. Each entry is either a list of collation element tuples (for direct lookup) or nil (indicating the codepoint must use the full lookup path).

Called automatically during table loading.

Returns

  • :ok.

lookup(cp)

@spec lookup(non_neg_integer()) :: [Localize.Collation.Element.t()] | nil

Look up collation elements for a Latin codepoint.

Arguments

  • cp - an integer codepoint less than 0x0180.

Returns

  • A list of collation element tuples - the codepoint has a direct mapping.

  • nil - the codepoint is a contraction starter, combining mark, or unmapped; use the full lookup path.