billthefarmer / diary

Android personal diary - forked from http://git.savannah.gnu.org/cgit/diary.git
https://billthefarmer.github.io/diary
GNU General Public License v3.0
276 stars 58 forks source link

"Custom calendar" takes very long to appear #75

Closed Self-Perfection closed 5 years ago

Self-Perfection commented 5 years ago

The more diary records there are, the longer it takes for custom calendar to appear after tapping "Go to date..."

I have a pretty extensive diary:

$ printf '%s\n' "$DIARY_PATH"/20??/??/??.txt | wc -l
1520

I.e. it has 1520 diary entries. And in my case custom calendar takes more than 20 seconds to appear. Device is Jolla C.

It is easy to reproduce, just create lots empty files as diary records:

mkdir -p  "$DIARY_PATH"/{2010..2018}/0{1..9}/ && \
touch  "$DIARY_PATH"/{2010..2018}/0{1..9}/{10..30}.txt

And try to open custom calendar. The more records are present, the longer it takes calendar to appear.

billthefarmer commented 5 years ago

This is because of the way I have implemented the calendar entry highlighting, by creating a list of entries and then searching it for matches. I will experiment with reversing the logic by checking if there is an entry for each date in the calendar.

billthefarmer commented 5 years ago

OK, that works, I tested it using your script on my 2012 Nexus 7. That will be in the next version.

Self-Perfection commented 5 years ago

Just tested version 1.33 from F-Droid and it shows custom calendar quite fast. Delay is less than 1s.

Thank you!