gstvalue: Minor list intersection optimization

When matching against the 2nd list, increment the starting position of the inner
list iteration.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/484>
This commit is contained in:
Edward Hervey 2020-05-14 11:32:39 +02:00 committed by Edward Hervey
parent 003b25f39d
commit 3c7db917dd

View file

@ -4798,7 +4798,7 @@ gst_value_intersect_list_list (GValue * dest, const GValue * value1,
gboolean res = FALSE;
GValue *tmp;
GType type1, type2;
guint it1, len1, it2, len2, itar;
guint it1, len1, start2, it2, len2, itar;
GstValueList *vlist = NULL;
/* If they don't have the same basic type, all bets are off :) */
@ -4849,10 +4849,11 @@ gst_value_intersect_list_list (GValue * dest, const GValue * value1,
itar = 0;
tmp = &vlist->fields[0];
start2 = 0;
for (it1 = 0; it1 < len1; it1++) {
const GValue *item1 = VALUE_LIST_GET_VALUE (value1, it1);
for (it2 = 0; it2 < len2; it2++) {
for (it2 = start2; it2 < len2; it2++) {
const GValue *item2;
if (is_visited (it2))
continue;
@ -4861,6 +4862,9 @@ gst_value_intersect_list_list (GValue * dest, const GValue * value1,
if (gst_value_intersect (tmp, item1, item2)) {
res = TRUE;
mark_visited (it2);
/* Increment our inner-loop starting point */
if (it2 == start2)
start2++;
/* Move our collection value */
itar += 1;