* range */
if (val < min || val > max) {
/* and the result is the int */
- gst_value_init_and_copy (dest, minuend);
+ if (dest)
+ gst_value_init_and_copy (dest, minuend);
return TRUE;
}
return FALSE;
return FALSE;
}
+ if (!dest)
+ return TRUE;
+
if (min1 < max1) {
g_value_init (pv1, GST_TYPE_INT_RANGE);
gst_value_set_int_range (pv1, min1, max1);
/* value is outside of the range, return range unchanged */
if (val < min || val > max) {
- gst_value_init_and_copy (dest, minuend);
+ if (dest)
+ gst_value_init_and_copy (dest, minuend);
return TRUE;
} else {
/* max must be MAXINT too as val <= max */
min++;
val++;
}
- gst_value_create_new_range (dest, min, val - 1, val + 1, max);
+ if (dest)
+ gst_value_create_new_range (dest, min, val - 1, val + 1, max);
}
return TRUE;
}
* range */
if (val < min || val > max) {
/* and the result is the int64 */
- gst_value_init_and_copy (dest, minuend);
+ if (dest)
+ gst_value_init_and_copy (dest, minuend);
return TRUE;
}
return FALSE;
return FALSE;
}
+ if (!dest)
+ return TRUE;
+
if (min1 < max1) {
g_value_init (pv1, GST_TYPE_INT64_RANGE);
gst_value_set_int64_range (pv1, min1, max1);
/* value is outside of the range, return range unchanged */
if (val < min || val > max) {
- gst_value_init_and_copy (dest, minuend);
+ if (dest)
+ gst_value_init_and_copy (dest, minuend);
return TRUE;
} else {
/* max must be MAXINT64 too as val <= max */
min++;
val++;
}
- gst_value_create_new_int64_range (dest, min, val - 1, val + 1, max);
+ if (dest)
+ gst_value_create_new_int64_range (dest, min, val - 1, val + 1, max);
}
return TRUE;
}
gdouble val = g_value_get_double (minuend);
if (val < min || val > max) {
- gst_value_init_and_copy (dest, minuend);
+ if (dest)
+ gst_value_init_and_copy (dest, minuend);
return TRUE;
}
return FALSE;
{
/* since we don't have open ranges, we cannot create a hole in
* a double range. We return the original range */
- gst_value_init_and_copy (dest, minuend);
+ if (dest)
+ gst_value_init_and_copy (dest, minuend);
return TRUE;
}
return FALSE;
}
+ if (!dest)
+ return TRUE;
+
if (min1 < max1) {
g_value_init (pv1, GST_TYPE_DOUBLE_RANGE);
gst_value_set_double_range (pv1, min1, max1);
for (i = 0; i < size; i++) {
const GValue *cur = VALUE_LIST_GET_VALUE (minuend, i);
+ /* quicker version when we can discard the result */
+ if (!dest) {
+ if (gst_value_subtract (NULL, cur, subtrahend)) {
+ ret = TRUE;
+ break;
+ }
+ continue;
+ }
+
if (gst_value_subtract (&subtraction, cur, subtrahend)) {
if (!ret) {
gst_value_init_and_copy (dest, &subtraction);
return FALSE;
}
}
- gst_value_init_and_copy (dest, result);
+ if (dest)
+ gst_value_init_and_copy (dest, result);
g_value_unset (result);
return TRUE;
}
gst_value_compare_with_func (minuend, max, compare) ==
GST_VALUE_GREATER_THAN) {
/* and the result is the value */
- gst_value_init_and_copy (dest, minuend);
+ if (dest)
+ gst_value_init_and_copy (dest, minuend);
return TRUE;
}
}
{
/* since we don't have open ranges, we cannot create a hole in
* a range. We return the original range */
- gst_value_init_and_copy (dest, minuend);
+ if (dest)
+ gst_value_init_and_copy (dest, minuend);
return TRUE;
}
return FALSE;
}
+ if (!dest)
+ return TRUE;
+
if (cmp1 == GST_VALUE_LESS_THAN) {
g_value_init (pv1, GST_TYPE_FRACTION_RANGE);
gst_value_set_fraction_range (pv1, min1, max1);
/**
* gst_value_subtract:
* @dest: (out caller-allocates): the destination value for the result if the
- * subtraction is not empty
+ * subtraction is not empty. May be NULL, in which case the resulting set
+ * will not be computed, which can give a fair speedup.
* @minuend: the value to subtract from
* @subtrahend: the value to subtract
*
guint i, len;
GType ltype, mtype, stype;
- g_return_val_if_fail (dest != NULL, FALSE);
g_return_val_if_fail (G_IS_VALUE (minuend), FALSE);
g_return_val_if_fail (G_IS_VALUE (subtrahend), FALSE);
}
if (gst_value_compare (minuend, subtrahend) != GST_VALUE_EQUAL) {
- gst_value_init_and_copy (dest, minuend);
+ if (dest)
+ gst_value_init_and_copy (dest, minuend);
return TRUE;
}