Code refactoring for using GList
- The loop to find listener over the GList are replaced to 'g_list_find_custom()'.
- The 'g_list_length()' is not fast because GList does not keep track of the number of items.
To reduce the 'g_list_length()' call, using index for a loop over the list are replaced
to using iterator.
To visit all elements in the list, use a loop over the list:
GList *l;
for (l = list; l != NULL; l = l->next)
{
// do something with l->data
}
reference: https://developer.gnome.org/glib/stable/glib-Doubly-Linked-Lists.html
Change-Id: Ic916d5ef9157b3c7574631b975351507f860fcb5