mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Change lru from double to single linked list. Only the font cache uses LRU and it never searches in reverse. Saves 2 bytes per glyph.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30818 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c032b9d083
commit
6f078c428f
2 changed files with 1 additions and 11 deletions
|
@ -33,7 +33,7 @@ struct lru
|
||||||
void *_base;
|
void *_base;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LRU_SLOT_OVERHEAD (2 * sizeof(short))
|
#define LRU_SLOT_OVERHEAD (1 * sizeof(short))
|
||||||
|
|
||||||
/* Create LRU list with specified size from buf. */
|
/* Create LRU list with specified size from buf. */
|
||||||
void lru_create(struct lru* pl, void *buf, short size, short data_size);
|
void lru_create(struct lru* pl, void *buf, short size, short data_size);
|
||||||
|
|
|
@ -48,11 +48,9 @@ void lru_create(struct lru* pl, void *buf, short size, short data_size)
|
||||||
for (i=0; i<pl->_size; i++)
|
for (i=0; i<pl->_size; i++)
|
||||||
{
|
{
|
||||||
lru_node_p(pl, i)->_next = i + 1;
|
lru_node_p(pl, i)->_next = i + 1;
|
||||||
lru_node_p(pl, i)->_prev = i - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fix up head and tail to form circular buffer */
|
/* Fix up head and tail to form circular buffer */
|
||||||
lru_node_p(pl, 0)->_prev = pl->_tail;
|
|
||||||
lru_node_p(pl, pl->_tail)->_next = pl->_head;
|
lru_node_p(pl, pl->_tail)->_next = pl->_head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,20 +90,12 @@ void lru_touch(struct lru* pl, short handle)
|
||||||
|
|
||||||
/* Remove current node from linked list */
|
/* Remove current node from linked list */
|
||||||
struct lru_node* curr_node = lru_node_p(pl, handle);
|
struct lru_node* curr_node = lru_node_p(pl, handle);
|
||||||
struct lru_node* prev_node = lru_node_p(pl, curr_node->_prev);
|
|
||||||
struct lru_node* next_node = lru_node_p(pl, curr_node->_next);
|
|
||||||
|
|
||||||
prev_node->_next = curr_node->_next;
|
|
||||||
next_node->_prev = curr_node->_prev;
|
|
||||||
|
|
||||||
/* insert current node at tail */
|
/* insert current node at tail */
|
||||||
struct lru_node* tail_node = lru_node_p(pl, pl->_tail);
|
struct lru_node* tail_node = lru_node_p(pl, pl->_tail);
|
||||||
short tail_node_next_handle = tail_node->_next; /* Bug fix */
|
short tail_node_next_handle = tail_node->_next; /* Bug fix */
|
||||||
struct lru_node* tail_node_next = lru_node_p(pl, tail_node_next_handle); /* Bug fix */
|
|
||||||
|
|
||||||
curr_node->_next = tail_node->_next;
|
curr_node->_next = tail_node->_next;
|
||||||
curr_node->_prev = pl->_tail;
|
|
||||||
tail_node_next->_prev = handle; /* Bug fix */
|
|
||||||
tail_node->_next = handle;
|
tail_node->_next = handle;
|
||||||
|
|
||||||
pl->_tail = handle;
|
pl->_tail = handle;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue