Files
Terminal.Gui/Terminal.Gui/Text
copilot-swe-agent[bot] d425e4edbf Fix TextFormatter.GetDrawRegion per-line allocations using ArrayPool
Applied ArrayPool pattern to GetDrawRegion method:
- Use ArrayPool<string>.Shared.Rent() instead of .ToArray() for grapheme arrays
- Track actual grapheme count separately from rented array length
- Return array to pool in finally block for guaranteed cleanup
- Handle rare case where array needs to grow during enumeration

Impact: Eliminates allocations on layout calculations
- GetDrawRegion called before drawing for text region calculations
- Same allocation pattern as Draw() which was already fixed
- Complements the Draw() optimization for complete text rendering pipeline

All unit tests pass (12,055 parallelizable + 1,173 non-parallel)

Co-authored-by: tig <585482+tig@users.noreply.github.com>
2025-12-03 20:46:45 +00:00
..