View Single Post
Old 01-24-2025, 05:58 PM   #785
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Comfy.n View Post
Thanks! I'm going to take a careful look at your recommendations later. Since you find that hard to read (it is, undoubtedly, but... that's how I managed to do the concatenations), I guess you'll find my "icons" column rule unimaginably chaotic:
No, this one is easy. Things are on separate lines and the function is clear.

For performance reasons I would suggest the following small modification. Instead of lines like this:
Code:
if 'EPUB' in $#f then icon = add_icon(icon, 'formats_epub.png') fi;
if 'AZW3' in $#f then icon = add_icon(icon, 'formats_azw3.png') fi;
Do this:
Code:
f = $#f;
if 'EPUB' in f then icon = add_icon(icon, 'formats_epub.png') fi;
if 'AZW3' in f then icon = add_icon(icon, 'formats_azw3.png') fi;
This way you evaluate the field variable only once instead of on every if line.

If you would accept alphabetic order instead of your if statement order then this would replace the long block of ifs. It isn't any faster but it is much more concise.
Code:
	for f in $#f:
		icon = add_icon('formats_' & lowercase(f))
	rof
The same thing will work in the languages section below.
chaley is offline   Reply With Quote