class TextLayoutCache
Swift
final class TextLayoutCache
Keyed on (text, font, quantized width, mode). Yoga measure is chatty; this is the main Phase 4 perf lever.
Sources/LavaUI/Font.swift:1082
Properties
var hitRate: Double { get }
Fraction of lookups answered from the cache; 1 when there have been none.
Sources/LavaUI/Font.swift:1131
var hits: Int { get }
Lookups answered from the cache since the last resetStats().
Sources/LavaUI/Font.swift:1114
var misses: Int { get }
Lookups that had to measure since the last resetStats().
Sources/LavaUI/Font.swift:1116
Methods
func clear()
Drops every cached layout and zeroes the statistics.
Sources/LavaUI/Font.swift:1125
func layout(font: UIFont, text: String, availWidth: Float, mode: Int) -> Entry
Measures and wraps text, from the cache when this exact question was
asked before.
mode is the Yoga measure mode: 0 undefined (one line per \n,
availWidth ignored), 1 exactly and 2 at most (wrap to availWidth).
Widths are compared at half-pixel precision.
Sources/LavaUI/Font.swift:1142
Types
struct Key
What a cached layout is looked up by: the text, the font's identity,
the available width and the Yoga measure mode.
Sources/LavaUI/Font.swift:1088