diff --git a/validate/gst/validate/gst-validate-utils.c b/validate/gst/validate/gst-validate-utils.c index d6c7d82fa2..2d3c0e13ec 100644 --- a/validate/gst/validate/gst-validate-utils.c +++ b/validate/gst/validate/gst-validate-utils.c @@ -1339,8 +1339,6 @@ done: static gboolean _structure_set_variables (GQuark field_id, GValue * value, ReplaceData * data) { - gchar *str; - if (field_id == filename_quark || field_id == debug_quark || field_id == debug_quark) return TRUE; @@ -1358,12 +1356,18 @@ _structure_set_variables (GQuark field_id, GValue * value, ReplaceData * data) if (!G_VALUE_HOLDS_STRING (value)) return TRUE; - str = - gst_validate_replace_variables_in_string (data->source, data->local_vars, - g_value_get_string (value), data->flags); - if (str) { - g_value_set_string (value, str); - g_free (str); + if (!_variables_regex) + _variables_regex = g_regex_new ("\\$\\((\\w+)\\)", 0, 0, NULL); + + /* Don't replace string contents unless really needed */ + if (g_regex_match (_variables_regex, g_value_get_string (value), 0, NULL)) { + gchar *str = gst_validate_replace_variables_in_string (data->source, + data->local_vars, + g_value_get_string (value), data->flags); + if (str) { + g_value_set_string (value, str); + g_free (str); + } } if (!(data->flags & GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_NO_EXPRESSION))