Quote:
|
Originally Posted by evilghost
It's fairly easy to find someone who doesn't know what they're doing.
|
Reminds me of the following piece of code:
Code:
int i;
for (i = 0; i < g_list_length(list); i++) {
struct whatever_data *data;
data = (struct whatever_data *) g_list_nth_data(list, i);
do_the_magic(data);
}
Someone clearly didn't know you can iterate through the list using linked_list->next (or by calling g_list_foreach(), but that would require a callback function). Although the list always had less than 80 elements, he would still use O(n^2) time instead of O(n). I hardly think GLib would have any internal indexing for GList. At least he didn't manually iterate to the n:th element inside the outer loop...