GNOME Bugzilla – Bug 756988
GSequence should document each function's complexity
Last modified: 2015-10-30 15:36:08 UTC
Following bug #756316, I think it's important to document the O() of each method. Not even GSequence authors themself knew that _get_length is not O(1) judging from the while (g_sequence_get_length (tmp) > 0) I see in g_sequence_sort_iter().
Created attachment 313892 [details] [review] GSequence: document that g_sequence_get_length() is not O(1)
Review of attachment 313892 [details] [review]: ::: glib/gsequence.c @@ +884,3 @@ tmp->access_prohibited = TRUE; + while (!g_sequence_is_empty (tmp)) This looks like a documentation patch but it contains code changes. Big no-no. Please clarify the commit message or (ideally) split this up.
Created attachment 314486 [details] [review] GSequence: Stop using _get_length() to check if it's empty g_sequence_is_empty() is more efficient for that task.
Created attachment 314487 [details] [review] GSequence: document that _get_length() is not O(1)
Created attachment 314488 [details] [review] GSequence: document that _get_length() is not O(1)
Created attachment 314489 [details] [review] Stop using g_sequence_get_length() to check if it's empty g_sequence_is_empty() is more efficient for that task.
A quick git grep gave many other places, fixed them as well now.
Review of attachment 314488 [details] [review]: ::: glib/gsequence.c @@ +1232,3 @@ * @seq: a #GSequence * + * Returns the length of @seq. Note that this method is O(h) where `h' is the Put a paragraph break here (ie: your text is a new separate paragraph). Otherwise, it's good. Thanks.
Review of attachment 314489 [details] [review]: OK.
Thanks.