GUI: U32: Improve splitting osd messages

Use iterators for construction instead of continous adding
This commit is contained in:
aryanrawlani28 2020-07-02 02:04:52 +05:30 committed by Eugene Sandulenko
parent d3e64b2df4
commit f46be5c766

View File

@ -2237,18 +2237,16 @@ void SurfaceSdlGraphicsManager::displayMessageOnOSD(const Common::U32String &msg
// Split the message into separate lines.
Common::Array<Common::U32String> lines;
Common::U32String singleMessage;
Common::U32String::const_iterator itr = msg.begin(), strLineItrBegin = msg.begin();
// GUI U32 TODO: This can be better optimized perhaps?
for (Common::U32String::const_iterator itr = msg.begin(); itr != msg.end(); itr++) {
for ( ; itr != msg.end(); itr++) {
if (*itr == '\n') {
lines.push_back(singleMessage);
singleMessage.clear();
continue;
lines.push_back(Common::U32String(strLineItrBegin, itr));
strLineItrBegin = itr + 1;
}
singleMessage += (*itr);
}
lines.push_back(singleMessage);
if (strLineItrBegin != msg.end())
lines.push_back(Common::U32String(strLineItrBegin, msg.end()));
// Determine a rect which would contain the message string (clipped to the
// screen dimensions).