How about having the last line in its own"staging" file?
All lines but one are in a StorageFile, last line is in a normal file. When editing or replacing the last line, just replace the normal file. On adding a line append the already stored line from the staging file to the StorageFile and write the new line to the staging file.
That should save both on CPU cycles and flash writes.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
How about having the last line in its own"staging" file?
All lines but one are in a StorageFile, last line is in a normal file. When editing or replacing the last line, just replace the normal file. On adding a line append the already stored line from the staging file to the StorageFile and write the new line to the staging file.
That should save both on CPU cycles and flash writes.