use raw wrapWidth ptr instead of Maybe

This commit is contained in:
Kae 2023-07-02 00:52:36 +10:00
parent 210d6326fc
commit 17af21fd42
3 changed files with 5 additions and 4 deletions

View File

@ -295,6 +295,7 @@ size_t StringView::findFirstNotOf(StringView pattern, size_t beg) const {
}
size_t StringView::findNextBoundary(size_t index, bool backwards) const {
//TODO: Make this faster.
size_t mySize = size();
starAssert(index <= mySize);
if (!backwards && (index == mySize))

View File

@ -206,7 +206,7 @@ int TextPainter::stringWidth(StringView s) {
return width;
}
bool TextPainter::processWrapText(StringView text, Maybe<unsigned> wrapWidth, WrapTextCallback textFunc) {
bool TextPainter::processWrapText(StringView text, unsigned* wrapWidth, WrapTextCallback textFunc) {
String font = m_renderSettings.font, setFont = font;
m_fontTextureGroup.switchFont(font);
int lines = 0;
@ -351,7 +351,7 @@ List<StringView> TextPainter::wrapTextViews(StringView s, Maybe<unsigned> wrapWi
return true;
};
processWrapText(s, wrapWidth, textCallback);
processWrapText(s, wrapWidth.ptr(), textCallback);
if (active)
views.push_back(current);
@ -374,7 +374,7 @@ StringList TextPainter::wrapText(StringView s, Maybe<unsigned> wrapWidth) {
return true;
};
processWrapText(s, wrapWidth, textCallback);
processWrapText(s, wrapWidth.ptr(), textCallback);
if (!current.empty())
result.append(move(current));

View File

@ -68,7 +68,7 @@ public:
typedef function<bool(StringView, int)> WrapTextCallback;
bool processWrapText(StringView s, Maybe<unsigned> wrapWidth, WrapTextCallback textFunc);
bool processWrapText(StringView s, unsigned* wrapWidth, WrapTextCallback textFunc);
List<StringView> wrapTextViews(StringView s, Maybe<unsigned> wrapWidth);
StringList wrapText(StringView s, Maybe<unsigned> wrapWidth);