From 077d02e8373c2b651b147bdc592ac2a09ca96601 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 7 Feb 2026 13:32:34 +1100 Subject: Use std::array for text measurement cases where it only adds a little code. --- src/EditView.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/EditView.cxx') diff --git a/src/EditView.cxx b/src/EditView.cxx index 59fa80055..11a81edb7 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -355,10 +356,10 @@ void LayoutSegments(IPositionCache *pCache, representationWidth = vstyle.controlCharWidth; if (representationWidth <= 0.0) { assert(ts.representation->stringRep.length() <= Representation::maxLength); - XYPOSITION positionsRepr[Representation::maxLength + 1]; + std::array positionsRepr; // ts.representation->stringRep is UTF-8. pCache->MeasureWidths(surface, vstyle, StyleControlChar, true, ts.representation->stringRep, - positionsRepr, multiThreaded); + positionsRepr.data(), multiThreaded); representationWidth = positionsRepr[ts.representation->stringRep.length() - 1]; if (FlagSet(ts.representation->appearance, RepresentationAppearance::Blob)) { representationWidth += vstyle.ctrlCharPadding; @@ -377,9 +378,9 @@ void LayoutSegments(IPositionCache *pCache, } } else if (vstyle.styles[styleSegment].invisibleRepresentation[0]) { const std::string_view text = vstyle.styles[styleSegment].invisibleRepresentation; - XYPOSITION positionsRepr[Representation::maxLength + 1]; + std::array positionsRepr; // invisibleRepresentation is UTF-8. - pCache->MeasureWidths(surface, vstyle, styleSegment, true, text, positionsRepr, multiThreaded); + pCache->MeasureWidths(surface, vstyle, styleSegment, true, text, positionsRepr.data(), multiThreaded); const XYPOSITION representationWidth = positionsRepr[text.length() - 1]; std::fill(positions, positions + ts.length, representationWidth); } -- cgit v1.2.3