pad: Break sticky event array iterations if the type is bigger than the one we look for

Microoptimization we can do because the array is sorted by type.
This commit is contained in:
Sebastian Dröge 2015-08-15 17:59:21 +02:00
parent 7f0e0ff3ca
commit 1176fbf6dc

View file

@ -471,6 +471,8 @@ find_event_by_type (GstPad * pad, GstEventType type, guint idx)
if (idx == 0)
goto found;
idx--;
} else if (GST_EVENT_TYPE (ev->event) > type) {
break;
}
}
ev = NULL;
@ -493,6 +495,8 @@ find_event (GstPad * pad, GstEvent * event)
ev = &g_array_index (events, PadEvent, i);
if (event == ev->event)
goto found;
else if (GST_EVENT_TYPE (ev->event) > GST_EVENT_TYPE (event))
break;
}
ev = NULL;
found:
@ -516,7 +520,9 @@ remove_event_by_type (GstPad * pad, GstEventType type)
if (ev->event == NULL)
goto next;
if (GST_EVENT_TYPE (ev->event) != type)
if (GST_EVENT_TYPE (ev->event) > type)
break;
else if (GST_EVENT_TYPE (ev->event) != type)
goto next;
gst_event_unref (ev->event);