View Single Post
Old 10-21-2024, 09:50 AM   #734
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 11,111
Karma: 77213681
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by chaley View Post
I'm not sure what you are asking.

If you are asking if it would be faster to use field_list_count() instead of $$#timesread then the answer is yes. In the best case where $$#timesread has already been evaluated for the book then the performance improvement will be around 2 times. If $$#timesread hasn't yet been evaluated for the book then the performance improvement is at least 10 times.

If you are using $#timesread (not raw_field()) then the performance improvement of using field_list_count() directly is probably 10 to 100 times.
Yes, specifically line three here:

Code:
program:
	status = readstatus();
	times = field_list_count('#datesread');
	readgoal = strcat('readinggoal:', format_date(today(), 'yyyy')) in $#admintags;

	switch_if(
		status=='read', 'Read',
		status=='didnotfinish', 'Did Not Finish',
		status=='currentlyreading', 
			if times >#0 then 'Currently Rereading' 
			else 'Currently Reading' fi,
		status=='toberead', 'To Be Read',
		status=='unread', 
			if readgoal && $$#lastread != 'None' then 'To Be Read' 
			elif readgoal then 'Backlog' 
			else 'Unread' fi,
		''
	)
When #timesread column used to be an integer, I used that for 'times.' Now that it's a composite, I switched to using field_list_count() directly.

I just realized I could probably speed up this template a nudge by turning those nested if-thens into switch_ifs.
ownedbycats is offline   Reply With Quote