diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-03-22 00:22:42 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2022-03-22 00:22:42 -0400 |
commit | 61bc7b91bc7bf904d196b132e9e862e059780783 (patch) | |
tree | 29abfc66b5b8c22d081e95efed4ca97f0e6daffc | |
parent | cfeeb7889d5346e2abaf9b198375df62c58b098f (diff) | |
download | rockbox-61bc7b91bc7bf904d196b132e9e862e059780783.tar.gz rockbox-61bc7b91bc7bf904d196b132e9e862e059780783.zip |
tagcache.c remove 16-bit compression for add_uniqbuf
apparently there are tags such as year or genre that are indexed 1 byte
apart, as much as I like the idea of this I cannot come up with a way
to reliably denote 2 16 bit entries from a single 32 bit entry without
losing data or adding bookkeeping which would likely make it pointless
Change-Id: I8a9908575700cab9506c36f5422222145557fa6b
-rw-r--r-- | apps/tagcache.c | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index f49a67924e..8bc742112b 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -1284,52 +1284,13 @@ static bool add_uniqbuf(struct tagcache_search *tcs, uint32_t id) | |||
1284 | return true; | 1284 | return true; |
1285 | } | 1285 | } |
1286 | 1286 | ||
1287 | if (id <= UINT16_MAX) | 1287 | for (i = 0; i < tcs->unique_list_count; i++) |
1288 | { | ||
1289 | /* place two 16-bit entries in a single 32-bit slot */ | ||
1290 | uint32_t idtmp; | ||
1291 | union uentry{ | ||
1292 | uint16_t u16[2]; | ||
1293 | uint32_t u32; | ||
1294 | } *entry; | ||
1295 | id |= 1; /*odd - flag 16-bit entry */ | ||
1296 | for (i = 0; i < tcs->unique_list_count; i++) | ||
1297 | { | ||
1298 | entry = (union uentry *) &tcs->unique_list[i]; | ||
1299 | if ((entry->u32 & 1) == 0) /* contains a 32-bit entry */ | ||
1300 | continue; | ||
1301 | |||
1302 | /* Return false if entry is found. */ | ||
1303 | if (entry->u16[0] == id || entry->u16[1] == id) | ||
1304 | { | ||
1305 | //logf("%d Exists (16) @ %d", id, i); | ||
1306 | return false; | ||
1307 | } | ||
1308 | |||
1309 | if (entry->u16[1] == 0 && (entry->u16[0] & 1) == 1) | ||
1310 | { | ||
1311 | entry->u16[1] = id & UINT16_MAX; | ||
1312 | return true; /*no more 16bit entries add to empty 16bit slot */ | ||
1313 | } | ||
1314 | |||
1315 | } | ||
1316 | /* Not Found and no empty slot add a new entry */ | ||
1317 | entry = (union uentry *) &idtmp; | ||
1318 | entry->u16[1] = 0; | ||
1319 | entry->u16[0] = id & UINT16_MAX; | ||
1320 | id = idtmp; | ||
1321 | } | ||
1322 | else | ||
1323 | { | 1288 | { |
1324 | id &= ~1; /* even - flag 32-bit entry */ | 1289 | /* Return false if entry is found. */ |
1325 | for (i = 0; i < tcs->unique_list_count; i++) | 1290 | if (tcs->unique_list[i] == id) |
1326 | { | 1291 | { |
1327 | /* Return false if entry is found. */ | 1292 | //logf("%d Exists @ %d", id, i); |
1328 | if (tcs->unique_list[i] == id) | 1293 | return false; |
1329 | { | ||
1330 | //logf("%d Exists (32)@ %d", id, i); | ||
1331 | return false; | ||
1332 | } | ||
1333 | } | 1294 | } |
1334 | } | 1295 | } |
1335 | 1296 | ||