mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-02 05:43:07 +02:00
tests: Simplify a helper function in queue test
Remove an unnecessary intermediate variable. This introduces no functional changes. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
ea852e2683
commit
eff90c09f5
@ -169,7 +169,6 @@ compare_int (gconstpointer a, gconstpointer b, gpointer data)
|
|||||||
static guint
|
static guint
|
||||||
get_random_position (GQueue *queue, gboolean allow_offlist)
|
get_random_position (GQueue *queue, gboolean allow_offlist)
|
||||||
{
|
{
|
||||||
guint n;
|
|
||||||
enum { OFF_QUEUE, HEAD, TAIL, MIDDLE, LAST } where;
|
enum { OFF_QUEUE, HEAD, TAIL, MIDDLE, LAST } where;
|
||||||
|
|
||||||
if (allow_offlist)
|
if (allow_offlist)
|
||||||
@ -180,37 +179,28 @@ get_random_position (GQueue *queue, gboolean allow_offlist)
|
|||||||
switch (where)
|
switch (where)
|
||||||
{
|
{
|
||||||
case OFF_QUEUE:
|
case OFF_QUEUE:
|
||||||
n = g_random_int ();
|
return g_random_int ();
|
||||||
break;
|
|
||||||
|
|
||||||
case HEAD:
|
case HEAD:
|
||||||
n = 0;
|
return 0;
|
||||||
break;
|
|
||||||
|
|
||||||
case TAIL:
|
case TAIL:
|
||||||
if (allow_offlist)
|
if (allow_offlist)
|
||||||
n = queue->length;
|
return queue->length;
|
||||||
else if (queue->length > 0)
|
else if (queue->length > 0)
|
||||||
n = queue->length - 1;
|
return queue->length - 1;
|
||||||
else
|
else
|
||||||
n = 0;
|
return 0;
|
||||||
break;
|
|
||||||
|
|
||||||
case MIDDLE:
|
case MIDDLE:
|
||||||
if (queue->length == 0)
|
if (queue->length == 0)
|
||||||
n = 0;
|
return 0;
|
||||||
else
|
else
|
||||||
n = g_random_int_range (0, queue->length);
|
return g_random_int_range (0, queue->length);
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached();
|
g_assert_not_reached ();
|
||||||
n = 100;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user