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
|
|
@ -81,4 +81,35 @@ public class UiDatFontTests
|
|||
Assert.Equal(0f, UiDatFont.MeasureWidth("", Lookup));
|
||||
Assert.Equal(0f, UiDatFont.MeasureWidth(null, Lookup));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InstanceMeasureWidth_ReusesGlyphTableWithoutAllocating()
|
||||
{
|
||||
var glyphs = new Dictionary<char, FontCharDesc>
|
||||
{
|
||||
['A'] = Glyph('A', width: 8, before: 1, after: 2),
|
||||
['B'] = Glyph('B', width: 7, before: 1, after: 1),
|
||||
};
|
||||
var font = new UiDatFont(
|
||||
fgTex: 0,
|
||||
fgW: 0,
|
||||
fgH: 0,
|
||||
bgTex: 0,
|
||||
bgW: 0,
|
||||
bgH: 0,
|
||||
lineHeight: 16f,
|
||||
baselineOffset: 12f,
|
||||
glyphs);
|
||||
const string Text = "ABBA";
|
||||
float expected = font.MeasureWidth(Text);
|
||||
float actual = 0f;
|
||||
long before = GC.GetAllocatedBytesForCurrentThread();
|
||||
|
||||
for (int iteration = 0; iteration < 10_000; iteration++)
|
||||
actual = font.MeasureWidth(Text);
|
||||
|
||||
long allocated = GC.GetAllocatedBytesForCurrentThread() - before;
|
||||
Assert.Equal(expected, actual);
|
||||
Assert.Equal(0, allocated);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue