Rewrite track metadata cache
commit40fa77b85d0f3876d62cd0d31a340aabef8729ed
authorTimo Hirvonen <tihirvon@gmail.com>
Mon, 28 Jan 2008 16:02:24 +0000 (28 18:02 +0200)
committerTimo Hirvonen <tihirvon@gmail.com>
Mon, 28 Jan 2008 16:25:37 +0000 (28 18:25 +0200)
treebd14930de3c601b47f2dae3e56d7adac14cac8b2
parentbe3c4c03b977bad894a42b5c71216f4d0075dd02
Rewrite track metadata cache

Store track metadata in one file (~/.cmus/cache) instead of two files
(data and index).  All data is converted to struct track_info and put
into a hash table.  This may sound like wasting memory but 582878 is not
that much when compared to size of the old index file (256561) which was
kept in memory.

Old sizes for 3263 tracks:
    327806 trackdb.dat
    256561 trackdb.idx
    584367 total

New size:
    582878 cache

This new cache consumes less memory if all tracks are in playlist
because there's no .idx data (filenames, offsets and sizes) in memory
anymore.

The new code is faster because data is read at once, not in small pieces
like the old code did.  Track metadata is hashed by filename so the
lookups should be much faster than in the old code which did binary
search over the index and then read data from the .dat file.
13 files changed:
Makefile
cache.c [new file with mode: 0644]
cache.h [new file with mode: 0644]
cmus.c
cmus.h
db.c [deleted file]
db.h [deleted file]
job.c
player.c
player.h
track_db.c [deleted file]
track_db.h [deleted file]
track_info.h