mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 22:57:50 +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
|
||||
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
|
||||
if (bookName.length() > 25) {
|
||||
bookName = bookName.substr(0, 22) + "...";
|
||||
bookName.resize(22);
|
||||
bookName += "...";
|
||||
}
|
||||
std::string continueLabel = "Continue: " + bookName;
|
||||
renderer.drawText(UI_FONT_ID, 20, menuY, continueLabel.c_str(), selectorIndex != menuIndex);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user