From 6c4ae7c41a4957b8b39245a55f20df2ca6d9d4e6 Mon Sep 17 00:00:00 2001 From: Zach Nelson Date: Mon, 4 May 2026 08:45:44 -0500 Subject: [PATCH] refactor: Avoid vector for page turn rates list (#1818) ## Summary Small cleanup to avoid a dynamically allocated static structure for auto page-turn rate values. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**NO**_ --- src/activities/reader/EpubReaderActivity.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 57eeb462..ea6ad2cc 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include "CrossPointSettings.h" @@ -31,7 +32,7 @@ namespace { // pagesPerRefresh now comes from SETTINGS.getRefreshFrequency() constexpr unsigned long skipChapterMs = 700; // pages per minute, first item is 1 to prevent division by zero if accessed -const std::vector PAGE_TURN_LABELS = {1, 1, 3, 6, 12}; +constexpr int PAGE_TURN_RATES[] = {1, 1, 3, 6, 12}; int clampPercent(int percent) { if (percent < 0) { @@ -469,14 +470,14 @@ void EpubReaderActivity::applyOrientation(const uint8_t orientation) { } void EpubReaderActivity::toggleAutoPageTurn(const uint8_t selectedPageTurnOption) { - if (selectedPageTurnOption == 0 || selectedPageTurnOption >= PAGE_TURN_LABELS.size()) { + if (selectedPageTurnOption == 0 || selectedPageTurnOption >= std::size(PAGE_TURN_RATES)) { automaticPageTurnActive = false; return; } lastPageTurnTime = millis(); // calculates page turn duration by dividing by number of pages - pageTurnDuration = (1UL * 60 * 1000) / PAGE_TURN_LABELS[selectedPageTurnOption]; + pageTurnDuration = (1UL * 60 * 1000) / PAGE_TURN_RATES[selectedPageTurnOption]; automaticPageTurnActive = true; const uint8_t statusBarHeight = UITheme::getInstance().getStatusBarHeight();