Reduce heap pressure
This commit is contained in:
@@ -68,7 +68,7 @@ void applyLegacyStatusBarSettings(CrossPointSettings& settings) {
|
|||||||
// ---- CrossPointState ----
|
// ---- CrossPointState ----
|
||||||
|
|
||||||
bool JsonSettingsIO::saveState(const CrossPointState& s, const char* path) {
|
bool JsonSettingsIO::saveState(const CrossPointState& s, const char* path) {
|
||||||
JsonDocument doc;
|
StaticJsonDocument<4096> doc;
|
||||||
doc["openEpubPath"] = s.openEpubPath;
|
doc["openEpubPath"] = s.openEpubPath;
|
||||||
doc["lastSleepImage"] = s.lastSleepImage;
|
doc["lastSleepImage"] = s.lastSleepImage;
|
||||||
doc["readerActivityLoadCount"] = s.readerActivityLoadCount;
|
doc["readerActivityLoadCount"] = s.readerActivityLoadCount;
|
||||||
@@ -95,9 +95,14 @@ bool JsonSettingsIO::saveState(const CrossPointState& s, const char* path) {
|
|||||||
jump["spineIndex"] = s.pendingBookmarkJump.spineIndex;
|
jump["spineIndex"] = s.pendingBookmarkJump.spineIndex;
|
||||||
jump["pageNumber"] = s.pendingBookmarkJump.pageNumber;
|
jump["pageNumber"] = s.pendingBookmarkJump.pageNumber;
|
||||||
|
|
||||||
String json;
|
FsFile file;
|
||||||
serializeJson(doc, json);
|
if (!Storage.openFileForWrite("CPS", path, file)) {
|
||||||
return Storage.writeFile(path, json);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t written = serializeJson(doc, file);
|
||||||
|
file.close();
|
||||||
|
return written > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JsonSettingsIO::loadState(CrossPointState& s, const char* json) {
|
bool JsonSettingsIO::loadState(CrossPointState& s, const char* json) {
|
||||||
|
|||||||
Reference in New Issue
Block a user