efreet mime types icon cache.
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 3 Mar 2009 07:20:21 +0000 (07:20 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 3 Mar 2009 07:20:21 +0000 (07:20 +0000)
commit0d229ce6fe30e80c1aa677d87016f38769031d07
treeda854649afa4b1b8052126e0d0f15cd3b2a41a13
parent7e7fd6f229133337096a8f6314f43dd86b89b719
efreet mime types icon cache.

This cache is very simple and should work fine when system does not
change, it keeps a direct association of mime-types and found icons,
remembering theme and icon size. Search is very fast since it uses
stringshared strings and thus direct pointer comparison in hash
search. We could optimize it even more if we assumed stringshared
strings to come in, so no need to eina_stringshare_add() (which is a
hash per se), using just eina_stringshare_ref().

Cache population is limited to compile-time value and just values
older than a given threshold are deleted. I do not keep a LRU explicit
list, so you might have some old but unused items always alive. I
don't find this too bad, sure it will consume more memory, but will
not hurt performance. We can change this to purge all expired items by
not checking for number of items to remove, removing all that match.

Next I plan to find out a good way to cache and speed up file->mime
discovery. I plan to do auto-generated state-machine to match
extensions, so you don't need to check the same extension character
more than once. Example:

   Input: bla.edc
   Extensions: edc edj eps png bmp

It would first try to match against 'e', 'p' and 'b'. It will match
'e' and then check for 'd' (edc or edj) or 'p' (eps). It will match
'd' and then check for 'c' or 'j'. This will reduce number of
comparisons considerably.

As I'm running out of time (4am, not much time left on this month), I
could use some help here.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/efreet@39343 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
src/lib/Efreet_Mime.h
src/lib/efreet_mime.c