Expand description
Grapheme pooling and interning.
The GraphemePool stores complex grapheme clusters (emoji, ZWJ sequences, etc.)
that donβt fit in CellContentβs 4-byte inline storage. It provides:
- Compact
GraphemeIdreferences (4 bytes) instead of heap strings per cell - Reference counting for automatic cleanup
- Deduplication via hash lookup
- Slot reuse via free list
Β§When to Use
Most cells use simple characters that fit inline in CellContent. The pool
is only needed for:
- Multi-codepoint emoji (π¨βπ©βπ§βπ¦, π§π½βπ», etc.)
- ZWJ sequences
- Complex combining character sequences
Β§Usage
use ftui_render::grapheme_pool::GraphemePool;
let mut pool = GraphemePool::new();
// Intern a grapheme
let id = pool.intern("π¨βπ©βπ§βπ¦", 2); // Family emoji, width 2
// Look it up
assert_eq!(pool.get(id), Some("π¨βπ©βπ§βπ¦"));
assert_eq!(id.width(), 2);
// Increment reference count when copied to another cell
pool.retain(id);
// Release when cell is overwritten
pool.release(id);
pool.release(id);
// After all references released, slot is freed
assert_eq!(pool.get(id), None);StructsΒ§
- Grapheme
Pool - A reference-counted pool for complex grapheme clusters.