perf(runtime): remove measured steady allocations
Eliminate boxed production surface-override enumeration, retain vital modifier projections until the enchantment registry mutates, and measure DAT font widths without allocating a captured delegate. Preserve exact hashes, spell stacking, and glyph advances with warmed zero-allocation tests. Validated by the focused rendering, UI, and spell suites, a zero-error Release build, and 8,409 passing Release tests with five pre-existing skips. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
574a6c454f
commit
feb80a67d9
6 changed files with 188 additions and 14 deletions
|
|
@ -62,7 +62,7 @@ public sealed class UiDatFont
|
|||
|
||||
private readonly Dictionary<char, FontCharDesc> _glyphs;
|
||||
|
||||
private UiDatFont(
|
||||
internal UiDatFont(
|
||||
uint fgTex, int fgW, int fgH,
|
||||
uint bgTex, int bgW, int bgH,
|
||||
float lineHeight, float baselineOffset,
|
||||
|
|
@ -131,7 +131,18 @@ public sealed class UiDatFont
|
|||
/// glyph's retail advance. Characters not in the font contribute nothing.
|
||||
/// </summary>
|
||||
public float MeasureWidth(string text)
|
||||
=> MeasureWidth(text, c => _glyphs.TryGetValue(c, out var g) ? g : null);
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return 0f;
|
||||
|
||||
float width = 0f;
|
||||
for (int index = 0; index < text.Length; index++)
|
||||
{
|
||||
if (_glyphs.TryGetValue(text[index], out FontCharDesc? glyph))
|
||||
width += GlyphAdvance(glyph);
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pure pen-advance summation seam: total width of <paramref name="text"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue