mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 01:48:15 +03:00
Change font::print_wrap text argument from std::string to const char*
We no longer need to pass a std::string object to the print and len functions - in fact, we often only have a C string that we want to print or get the visual width of (that C string most often comes from loc::gettext), and it's a bit wasteful to wrap it in a new std::string object on every print/len call. This does mean adding a few more .c_str()s, but there's not many places where a std::string is being passed to these functions, and we already use .c_str() sometimes. -> Commit 1/3: font::print_wrap Commit 2/3: font::print Commit 3/3: font::len
This commit is contained in:
committed by
Misa Elizabeth Kai
parent
58d21e956b
commit
264b6474be
@@ -1261,7 +1261,7 @@ int print_wrap(
|
||||
uint32_t flags,
|
||||
const int x,
|
||||
int y,
|
||||
const std::string& text,
|
||||
const char* text,
|
||||
const uint8_t r,
|
||||
const uint8_t g,
|
||||
const uint8_t b,
|
||||
@@ -1292,7 +1292,6 @@ int print_wrap(
|
||||
flags &= ~PR_BOR;
|
||||
}
|
||||
|
||||
const char* str = text.c_str();
|
||||
// This could fit 64 non-BMP characters onscreen, should be plenty
|
||||
char buffer[256];
|
||||
size_t start = 0;
|
||||
@@ -1301,7 +1300,7 @@ int print_wrap(
|
||||
{
|
||||
// Correct for the height of the resulting print.
|
||||
size_t len = 0;
|
||||
while (next_wrap(pf.font_sel, &start, &len, &str[start], maxwidth))
|
||||
while (next_wrap(pf.font_sel, &start, &len, &text[start], maxwidth))
|
||||
{
|
||||
y += linespacing;
|
||||
}
|
||||
@@ -1309,7 +1308,7 @@ int print_wrap(
|
||||
start = 0;
|
||||
}
|
||||
|
||||
while (next_wrap_buf(pf.font_sel, buffer, sizeof(buffer), &start, str, maxwidth))
|
||||
while (next_wrap_buf(pf.font_sel, buffer, sizeof(buffer), &start, text, maxwidth))
|
||||
{
|
||||
print(flags, x, y, buffer, r, g, b);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user