perf(home): use resize() instead of substr() for string truncation

This commit is contained in:
Eunchurn Park 2025-12-26 02:31:30 +09:00
parent 6d041c9a18
commit 72d17626dd
No known key found for this signature in database
GPG Key ID: 29D94D9C697E3F92

View File

@ -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);