mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-11 03:46:17 +01:00
gsequence: Add seq_is_end()
This avoids calling is_end() when the GSequence is already determined, thus avoids having to walk the tree. https://bugzilla.gnome.org/show_bug.cgi?id=749583
This commit is contained in:
parent
ee8f7be3df
commit
6aa19a26cf
@ -175,6 +175,13 @@ get_sequence (GSequenceNode *node)
|
|||||||
return (GSequence *)node_get_last (node)->data;
|
return (GSequence *)node_get_last (node)->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
seq_is_end (GSequence *seq,
|
||||||
|
GSequenceIter *iter)
|
||||||
|
{
|
||||||
|
return seq->end_node == iter;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
is_end (GSequenceIter *iter)
|
is_end (GSequenceIter *iter)
|
||||||
{
|
{
|
||||||
@ -533,9 +540,10 @@ g_sequence_remove (GSequenceIter *iter)
|
|||||||
GSequence *seq;
|
GSequence *seq;
|
||||||
|
|
||||||
g_return_if_fail (iter != NULL);
|
g_return_if_fail (iter != NULL);
|
||||||
g_return_if_fail (!is_end (iter));
|
|
||||||
|
|
||||||
seq = get_sequence (iter);
|
seq = get_sequence (iter);
|
||||||
|
g_return_if_fail (!seq_is_end (seq, iter));
|
||||||
|
|
||||||
check_seq_access (seq);
|
check_seq_access (seq);
|
||||||
|
|
||||||
node_unlink (iter);
|
node_unlink (iter);
|
||||||
@ -748,10 +756,11 @@ g_sequence_sort_changed (GSequenceIter *iter,
|
|||||||
GSequence *seq;
|
GSequence *seq;
|
||||||
SortInfo info;
|
SortInfo info;
|
||||||
|
|
||||||
g_return_if_fail (!is_end (iter));
|
g_return_if_fail (iter != NULL);
|
||||||
|
|
||||||
seq = get_sequence (iter);
|
seq = get_sequence (iter);
|
||||||
/* check_seq_access() call is done by g_sequence_sort_changed_iter() */
|
/* check_seq_access() call is done by g_sequence_sort_changed_iter() */
|
||||||
|
g_return_if_fail (!seq_is_end (seq, iter));
|
||||||
|
|
||||||
info.cmp_func = cmp_func;
|
info.cmp_func = cmp_func;
|
||||||
info.cmp_data = cmp_data;
|
info.cmp_data = cmp_data;
|
||||||
@ -935,10 +944,11 @@ g_sequence_sort_changed_iter (GSequenceIter *iter,
|
|||||||
GSequenceIter *next, *prev;
|
GSequenceIter *next, *prev;
|
||||||
|
|
||||||
g_return_if_fail (iter != NULL);
|
g_return_if_fail (iter != NULL);
|
||||||
g_return_if_fail (!is_end (iter));
|
|
||||||
g_return_if_fail (iter_cmp != NULL);
|
g_return_if_fail (iter_cmp != NULL);
|
||||||
|
|
||||||
seq = get_sequence (iter);
|
seq = get_sequence (iter);
|
||||||
|
g_return_if_fail (!seq_is_end (seq, iter));
|
||||||
|
|
||||||
check_seq_access (seq);
|
check_seq_access (seq);
|
||||||
|
|
||||||
/* If one of the neighbours is equal to iter, then
|
/* If one of the neighbours is equal to iter, then
|
||||||
@ -1220,9 +1230,9 @@ g_sequence_set (GSequenceIter *iter,
|
|||||||
GSequence *seq;
|
GSequence *seq;
|
||||||
|
|
||||||
g_return_if_fail (iter != NULL);
|
g_return_if_fail (iter != NULL);
|
||||||
g_return_if_fail (!is_end (iter));
|
|
||||||
|
|
||||||
seq = get_sequence (iter);
|
seq = get_sequence (iter);
|
||||||
|
g_return_if_fail (!seq_is_end (seq, iter));
|
||||||
|
|
||||||
/* If @data is identical to iter->data, it is destroyed
|
/* If @data is identical to iter->data, it is destroyed
|
||||||
* here. This will work right in case of ref-counted objects. Also
|
* here. This will work right in case of ref-counted objects. Also
|
||||||
|
Loading…
Reference in New Issue
Block a user