core/queue: Remove unused queue_erase() function

It's just added complexity that we don't need to keep around at this
point.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-09-12 07:39:13 -04:00
parent b17585237a
commit 9fa5f0b0db
4 changed files with 1 additions and 71 deletions

View File

@ -79,15 +79,6 @@ static inline unsigned int __queue_add_sorted(struct queue *queue,
return __queue_add_tail(queue, track);
}
static inline bool __queue_erase(struct queue *queue, struct queue_iter *it)
{
struct track *track = queue_iter_val(it);
if (queue->q_ops)
return queue->q_ops->qop_erase(queue, track);
return true;
}
static inline void __queue_remove(struct queue *queue, struct queue_iter *it)
{
struct track *track = queue_iter_val(it);
@ -240,27 +231,6 @@ unsigned int queue_add_front(struct queue *queue, struct track *track)
return __queue_add_head(queue, track);
}
void queue_erase(struct queue *queue, unsigned int index)
{
struct queue_iter it;
queue_iter_set(queue, &it, index);
if (__queue_erase(queue, &it))
__queue_remove(queue, &it);
}
void queue_erase_track(struct queue *queue, struct track *track)
{
struct queue_iter it;
queue_for_each(queue, &it) {
if (queue_iter_val(&it) == track) {
queue_erase(queue, it.it_pos);
return;
}
}
}
void queue_remove(struct queue *queue, unsigned int index)
{
struct queue_iter it;

View File

@ -65,17 +65,11 @@ static void __gui_playlist_updated(struct queue *queue, unsigned int n)
gui_model_update(queue->q_private, n);
}
static bool __gui_playlist_erase(struct queue *queue, struct track *track)
{
return false;
}
struct queue_ops playlist_ops = {
.qop_init = __gui_playlist_init,
.qop_deinit = __gui_playlist_deinit,
.qop_added = __gui_playlist_added,
.qop_erase = __gui_playlist_erase,
.qop_removed = __gui_playlist_removed,
.qop_cleared = __gui_playlist_cleared,
.qop_updated = __gui_playlist_updated,

View File

@ -37,9 +37,6 @@ struct queue_ops {
/* Called to tell a higher layer that a track has been added. */
void (*qop_added)(struct queue *, unsigned int);
/* Called to ask a higher layer if a track can be erased. */
bool (*qop_erase)(struct queue *, struct track *);
/* Called to tell a higher layer that a track has been removed. */
void (*qop_removed)(struct queue *, unsigned int);
@ -161,15 +158,6 @@ unsigned int queue_add(struct queue *, struct track *);
/* Called to add a track to the front of the queue. */
unsigned int queue_add_front(struct queue *, struct track *);
/*
* Called to erase a track from the queue by index.
* This can be prevented if qop_erase() returns "false".
*/
void queue_erase(struct queue *, unsigned int);
/* Called to erase a track from the queue */
void queue_erase_track(struct queue *, struct track *);
/* Called to remove a track from the queue by index. */
void queue_remove(struct queue *, unsigned int);

View File

@ -10,13 +10,10 @@
unsigned int count_init = 0;
unsigned int count_deinit = 0;
unsigned int count_added = 0;
unsigned int count_erase = 0;
unsigned int count_deleted = 0;
unsigned int count_cleared = 0;
unsigned int count_updated = 0;
bool can_erase = true;
static void *queue_op_init(struct queue *queue, void *data)
{
@ -34,12 +31,6 @@ static void queue_op_added(struct queue *queue, unsigned int pos)
count_added++;
}
static bool queue_op_erase(struct queue *queue, struct track *track)
{
count_erase++;
return can_erase;
}
static void queue_op_removed(struct queue *queue, unsigned int pos)
{
count_deleted++;
@ -60,7 +51,6 @@ static const struct queue_ops test_ops = {
.qop_init = queue_op_init,
.qop_deinit = queue_op_deinit,
.qop_added = queue_op_added,
.qop_erase = queue_op_erase,
.qop_removed = queue_op_removed,
.qop_cleared = queue_op_cleared,
.qop_updated = queue_op_updated,
@ -187,25 +177,13 @@ static void test_queue(gconstpointer arg)
g_assert_cmpuint(queue_size(&q), ==, ex_size);
g_assert_false(queue_has(&q, track));
/* queue_erase() = false */
can_erase = false;
for (i = 0; i < ex_size; i += 11) {
queue_erase(&q, i);
g_assert_cmpuint(q.q_length, ==, ex_length);
g_assert_cmpuint(queue_size(&q), ==, ex_size);
}
/* queue_remove() and queue_erase() == true */
can_erase = true;
track = track_get(1);
ex_length -= track->tr_length * (N / 13);
ex_size -= (N / 13);
for (i = 0; i < ex_size; i += 11) {
g_assert(queue_at(&q, i) == track);
if (i % 2 == 0)
queue_remove(&q, i);
else
queue_erase(&q, i);
queue_remove(&q, i);
}
g_assert_cmpuint(q.q_length, ==, ex_length);
g_assert_cmpuint(queue_size(&q), ==, ex_size);