mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 15:17:37 +03:00
perf(home): use resize() instead of substr() for string truncation
This commit is contained in:
parent
6d041c9a18
commit
72d17626dd
@ -121,11 +121,12 @@ void HomeActivity::render() const {
|
|||||||
}
|
}
|
||||||
// Remove .epub extension
|
// Remove .epub extension
|
||||||
if (bookName.length() > 5 && bookName.substr(bookName.length() - 5) == ".epub") {
|
if (bookName.length() > 5 && bookName.substr(bookName.length() - 5) == ".epub") {
|
||||||
bookName = bookName.substr(0, bookName.length() - 5);
|
bookName.resize(bookName.length() - 5);
|
||||||
}
|
}
|
||||||
// Truncate if too long
|
// Truncate if too long
|
||||||
if (bookName.length() > 25) {
|
if (bookName.length() > 25) {
|
||||||
bookName = bookName.substr(0, 22) + "...";
|
bookName.resize(22);
|
||||||
|
bookName += "...";
|
||||||
}
|
}
|
||||||
std::string continueLabel = "Continue: " + bookName;
|
std::string continueLabel = "Continue: " + bookName;
|
||||||
renderer.drawText(UI_FONT_ID, 20, menuY, continueLabel.c_str(), selectorIndex != menuIndex);
|
renderer.drawText(UI_FONT_ID, 20, menuY, continueLabel.c_str(), selectorIndex != menuIndex);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user