Commit d55ed544 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

minor optimizations: (g_list_append): `if' optimized for common code path,

Mon Dec 15 19:33:58 1997  Tim Janik  <timj@psynet.net>

        * glist.c: minor optimizations:
        (g_list_append): `if' optimized for common code path, commented out
        unneccessary `assert', saved one variable assignment.
        (g_list_prepend): saved two (conditioned) variable assignment.
        (g_list_insert): saved one  (conditioned) variable assignment,
        saved one variable assignment.
        (g_list_remove): `if' optimized for common code path, saved two
        variable assignments by using `g_list_free_1' (which is even
        faster) instead of `g_list_free'.
        (g_list_reverse): saved allocation of one variable, saved one
        variable assignment.
parent 4d724c25
Mon Dec 15 19:33:58 1997 Tim Janik <timj@psynet.net>
* glist.c: minor optimizations:
(g_list_append): `if' optimized for common code path, commented out
unneccessary `assert', saved one variable assignment.
(g_list_prepend): saved two (conditioned) variable assignment.
(g_list_insert): saved one (conditioned) variable assignment,
saved one variable assignment.
(g_list_remove): `if' optimized for common code path, saved two
variable assignments by using `g_list_free_1' (which is even
faster) instead of `g_list_free'.
(g_list_reverse): saved allocation of one variable, saved one
variable assignment.
Wed Dec 10 23:27:20 1997 Tim Janik <timj@psynet.net>
* glib_pre1.h:
......
......@@ -134,19 +134,17 @@ g_list_append (GList *list,
new_list = g_list_alloc ();
new_list->data = data;
if (!list)
{
list = new_list;
}
else
if (list)
{
last = g_list_last (list);
g_assert (last != NULL);
/* g_assert (last != NULL); */
last->next = new_list;
new_list->prev = last;
}
return list;
}
else
return new_list;
}
GList*
......@@ -161,11 +159,13 @@ g_list_prepend (GList *list,
if (list)
{
if (list->prev)
{
list->prev->next = new_list;
new_list->prev = list->prev;
list->prev = new_list;
}
list->prev = new_list;
new_list->next = list;
}
return new_list;
}
......@@ -191,14 +191,16 @@ g_list_insert (GList *list,
new_list->data = data;
if (tmp_list->prev)
{
tmp_list->prev->next = new_list;
new_list->next = tmp_list;
new_list->prev = tmp_list->prev;
}
new_list->next = tmp_list;
tmp_list->prev = new_list;
if (tmp_list == list)
list = new_list;
return new_list;
else
return list;
}
......@@ -229,7 +231,9 @@ g_list_remove (GList *list,
tmp = list;
while (tmp)
{
if (tmp->data == data)
if (tmp->data != data)
tmp = tmp->next;
else
{
if (tmp->prev)
tmp->prev->next = tmp->next;
......@@ -239,14 +243,10 @@ g_list_remove (GList *list,
if (list == tmp)
list = list->next;
tmp->next = NULL;
tmp->prev = NULL;
g_list_free (tmp);
g_list_free_1 (tmp);
break;
}
tmp = tmp->next;
}
return list;
}
......@@ -275,17 +275,15 @@ g_list_remove_link (GList *list,
GList*
g_list_reverse (GList *list)
{
GList *tmp;
GList *last;
last = NULL;
while (list)
{
last = list;
tmp = list->next;
list->next = list->prev;
list->prev = tmp;
list = tmp;
list = last->next;
last->next = last->prev;
last->prev = list;
}
return last;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment