diff options
author | Edward Hervey <bilboed@bilboed.com> | 2009-06-29 11:20:12 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2009-06-30 16:29:50 +0200 |
commit | 923913984e3b6448c9b9bae6d17a52a6f7a33646 (patch) | |
tree | 263f6ddd1a603bc71897e3760c24183daa40a1f5 | |
parent | 53b09c392ad1cb2325b2df498dcf6e7668ed22b6 (diff) |
Use local variables in for/while loops.
This makes the generated code faster since:
* It won't have to read an undirect value (which will most likely be
outside of the L1/L2 cache)
* We know that value never changes (the compiler has no clue that it doesn't).
-rw-r--r-- | gst/gstpad.c | 20 | ||||
-rw-r--r-- | gst/gstregistrybinary.c | 11 | ||||
-rw-r--r-- | gst/gstvalue.c | 78 |
3 files changed, 64 insertions, 45 deletions
diff --git a/gst/gstpad.c b/gst/gstpad.c index 9dc09ef63e..20069f6957 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c | |||
@@ -146,9 +146,7 @@ static GstFlowQuarks flow_quarks[] = { | |||
146 | {GST_FLOW_NOT_NEGOTIATED, "not-negotiated", 0}, | 146 | {GST_FLOW_NOT_NEGOTIATED, "not-negotiated", 0}, |
147 | {GST_FLOW_ERROR, "error", 0}, | 147 | {GST_FLOW_ERROR, "error", 0}, |
148 | {GST_FLOW_NOT_SUPPORTED, "not-supported", 0}, | 148 | {GST_FLOW_NOT_SUPPORTED, "not-supported", 0}, |
149 | {GST_FLOW_CUSTOM_ERROR, "custom-error", 0}, | 149 | {GST_FLOW_CUSTOM_ERROR, "custom-error", 0} |
150 | |||
151 | {0, NULL, 0} | ||
152 | }; | 150 | }; |
153 | 151 | ||
154 | /** | 152 | /** |
@@ -166,7 +164,7 @@ gst_flow_get_name (GstFlowReturn ret) | |||
166 | 164 | ||
167 | ret = CLAMP (ret, GST_FLOW_CUSTOM_ERROR, GST_FLOW_CUSTOM_SUCCESS); | 165 | ret = CLAMP (ret, GST_FLOW_CUSTOM_ERROR, GST_FLOW_CUSTOM_SUCCESS); |
168 | 166 | ||
169 | for (i = 0; flow_quarks[i].name; i++) { | 167 | for (i = 0; i < G_N_ELEMENTS (flow_quarks); i++) { |
170 | if (ret == flow_quarks[i].ret) | 168 | if (ret == flow_quarks[i].ret) |
171 | return flow_quarks[i].name; | 169 | return flow_quarks[i].name; |
172 | } | 170 | } |
@@ -189,7 +187,7 @@ gst_flow_to_quark (GstFlowReturn ret) | |||
189 | 187 | ||
190 | ret = CLAMP (ret, GST_FLOW_CUSTOM_ERROR, GST_FLOW_CUSTOM_SUCCESS); | 188 | ret = CLAMP (ret, GST_FLOW_CUSTOM_ERROR, GST_FLOW_CUSTOM_SUCCESS); |
191 | 189 | ||
192 | for (i = 0; flow_quarks[i].name; i++) { | 190 | for (i = 0; i < G_N_ELEMENTS (flow_quarks); i++) { |
193 | if (ret == flow_quarks[i].ret) | 191 | if (ret == flow_quarks[i].ret) |
194 | return flow_quarks[i].quark; | 192 | return flow_quarks[i].quark; |
195 | } | 193 | } |
@@ -203,7 +201,7 @@ gst_flow_to_quark (GstFlowReturn ret) | |||
203 | buffer_quark = g_quark_from_static_string ("buffer"); \ | 201 | buffer_quark = g_quark_from_static_string ("buffer"); \ |
204 | event_quark = g_quark_from_static_string ("event"); \ | 202 | event_quark = g_quark_from_static_string ("event"); \ |
205 | \ | 203 | \ |
206 | for (i = 0; flow_quarks[i].name; i++) { \ | 204 | for (i = 0; i < G_N_ELEMENTS (flow_quarks); i++) { \ |
207 | flow_quarks[i].quark = g_quark_from_static_string (flow_quarks[i].name); \ | 205 | flow_quarks[i].quark = g_quark_from_static_string (flow_quarks[i].name); \ |
208 | } \ | 206 | } \ |
209 | \ | 207 | \ |
@@ -2293,10 +2291,11 @@ fixate_value (GValue * dest, const GValue * src) | |||
2293 | g_value_unset (&temp); | 2291 | g_value_unset (&temp); |
2294 | } else if (G_VALUE_TYPE (src) == GST_TYPE_ARRAY) { | 2292 | } else if (G_VALUE_TYPE (src) == GST_TYPE_ARRAY) { |
2295 | gboolean res = FALSE; | 2293 | gboolean res = FALSE; |
2296 | guint n; | 2294 | guint n, len; |
2297 | 2295 | ||
2296 | len = gst_value_array_get_size (src); | ||
2298 | g_value_init (dest, GST_TYPE_ARRAY); | 2297 | g_value_init (dest, GST_TYPE_ARRAY); |
2299 | for (n = 0; n < gst_value_array_get_size (src); n++) { | 2298 | for (n = 0; n < len; n++) { |
2300 | GValue kid = { 0 }; | 2299 | GValue kid = { 0 }; |
2301 | const GValue *orig_kid = gst_value_array_get_value (src, n); | 2300 | const GValue *orig_kid = gst_value_array_get_value (src, n); |
2302 | 2301 | ||
@@ -2345,7 +2344,7 @@ void | |||
2345 | gst_pad_fixate_caps (GstPad * pad, GstCaps * caps) | 2344 | gst_pad_fixate_caps (GstPad * pad, GstCaps * caps) |
2346 | { | 2345 | { |
2347 | GstPadFixateCapsFunction fixatefunc; | 2346 | GstPadFixateCapsFunction fixatefunc; |
2348 | guint n; | 2347 | guint n, len; |
2349 | 2348 | ||
2350 | g_return_if_fail (GST_IS_PAD (pad)); | 2349 | g_return_if_fail (GST_IS_PAD (pad)); |
2351 | g_return_if_fail (caps != NULL); | 2350 | g_return_if_fail (caps != NULL); |
@@ -2359,7 +2358,8 @@ gst_pad_fixate_caps (GstPad * pad, GstCaps * caps) | |||
2359 | } | 2358 | } |
2360 | 2359 | ||
2361 | /* default fixation */ | 2360 | /* default fixation */ |
2362 | for (n = 0; n < gst_caps_get_size (caps); n++) { | 2361 | len = gst_caps_get_size (caps); |
2362 | for (n = 0; n < len; n++) { | ||
2363 | GstStructure *s = gst_caps_get_structure (caps, n); | 2363 | GstStructure *s = gst_caps_get_structure (caps, n); |
2364 | 2364 | ||
2365 | gst_structure_foreach (s, gst_pad_default_fixate, s); | 2365 | gst_structure_foreach (s, gst_pad_default_fixate, s); |
diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c index 654354a91b..c24e191c0e 100644 --- a/gst/gstregistrybinary.c +++ b/gst/gstregistrybinary.c | |||
@@ -1120,7 +1120,7 @@ gst_registry_binary_load_plugin (GstRegistry * registry, gchar ** in, | |||
1120 | GstBinaryPluginElement *pe; | 1120 | GstBinaryPluginElement *pe; |
1121 | GstPlugin *plugin = NULL; | 1121 | GstPlugin *plugin = NULL; |
1122 | gchar *cache_str = NULL; | 1122 | gchar *cache_str = NULL; |
1123 | guint i; | 1123 | guint i, n; |
1124 | 1124 | ||
1125 | align (*in); | 1125 | align (*in); |
1126 | GST_LOG ("Reading/casting for GstBinaryPluginElement at address %p", *in); | 1126 | GST_LOG ("Reading/casting for GstBinaryPluginElement at address %p", *in); |
@@ -1162,13 +1162,14 @@ gst_registry_binary_load_plugin (GstRegistry * registry, gchar ** in, | |||
1162 | 1162 | ||
1163 | /* Takes ownership of plugin */ | 1163 | /* Takes ownership of plugin */ |
1164 | gst_registry_add_plugin (registry, plugin); | 1164 | gst_registry_add_plugin (registry, plugin); |
1165 | n = pe->nfeatures; | ||
1165 | GST_DEBUG ("Added plugin '%s' plugin with %d features from binary registry", | 1166 | GST_DEBUG ("Added plugin '%s' plugin with %d features from binary registry", |
1166 | plugin->desc.name, pe->nfeatures); | 1167 | plugin->desc.name, n); |
1167 | 1168 | ||
1168 | /* Load plugin features */ | 1169 | /* Load plugin features */ |
1169 | for (i = 0; i < pe->nfeatures; i++) { | 1170 | for (i = 0; i < n; i++) { |
1170 | if (!gst_registry_binary_load_feature (registry, in, end, | 1171 | if (G_UNLIKELY (!gst_registry_binary_load_feature (registry, in, end, |
1171 | plugin->desc.name)) { | 1172 | plugin->desc.name))) { |
1172 | GST_ERROR ("Error while loading binary feature"); | 1173 | GST_ERROR ("Error while loading binary feature"); |
1173 | gst_registry_remove_plugin (registry, plugin); | 1174 | gst_registry_remove_plugin (registry, plugin); |
1174 | goto fail; | 1175 | goto fail; |
diff --git a/gst/gstvalue.c b/gst/gstvalue.c index ef647cef9f..bbcfa1d4ac 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c | |||
@@ -125,16 +125,17 @@ gst_value_serialize_any_list (const GValue * value, const gchar * begin, | |||
125 | GString *s; | 125 | GString *s; |
126 | GValue *v; | 126 | GValue *v; |
127 | gchar *s_val; | 127 | gchar *s_val; |
128 | guint alen = array->len; | ||
128 | 129 | ||
129 | /* estimate minimum string length to minimise re-allocs in GString */ | 130 | /* estimate minimum string length to minimise re-allocs in GString */ |
130 | s = g_string_sized_new (2 + (6 * array->len) + 2); | 131 | s = g_string_sized_new (2 + (6 * alen) + 2); |
131 | g_string_append (s, begin); | 132 | g_string_append (s, begin); |
132 | for (i = 0; i < array->len; i++) { | 133 | for (i = 0; i < alen; i++) { |
133 | v = &g_array_index (array, GValue, i); | 134 | v = &g_array_index (array, GValue, i); |
134 | s_val = gst_value_serialize (v); | 135 | s_val = gst_value_serialize (v); |
135 | g_string_append (s, s_val); | 136 | g_string_append (s, s_val); |
136 | g_free (s_val); | 137 | g_free (s_val); |
137 | if (i < array->len - 1) { | 138 | if (i < alen - 1) { |
138 | g_string_append_len (s, ", ", 2); | 139 | g_string_append_len (s, ", ", 2); |
139 | } | 140 | } |
140 | } | 141 | } |
@@ -151,13 +152,15 @@ gst_value_transform_any_list_string (const GValue * src_value, | |||
151 | GString *s; | 152 | GString *s; |
152 | guint i; | 153 | guint i; |
153 | gchar *list_s; | 154 | gchar *list_s; |
155 | guint alen; | ||
154 | 156 | ||
155 | array = src_value->data[0].v_pointer; | 157 | array = src_value->data[0].v_pointer; |
158 | alen = array->len; | ||
156 | 159 | ||
157 | /* estimate minimum string length to minimise re-allocs in GString */ | 160 | /* estimate minimum string length to minimise re-allocs in GString */ |
158 | s = g_string_sized_new (2 + (10 * array->len) + 2); | 161 | s = g_string_sized_new (2 + (10 * alen) + 2); |
159 | g_string_append (s, begin); | 162 | g_string_append (s, begin); |
160 | for (i = 0; i < array->len; i++) { | 163 | for (i = 0; i < alen; i++) { |
161 | list_value = &g_array_index (array, GValue, i); | 164 | list_value = &g_array_index (array, GValue, i); |
162 | 165 | ||
163 | if (i != 0) { | 166 | if (i != 0) { |
@@ -213,11 +216,12 @@ static GArray * | |||
213 | copy_garray_of_gstvalue (const GArray * src) | 216 | copy_garray_of_gstvalue (const GArray * src) |
214 | { | 217 | { |
215 | GArray *dest; | 218 | GArray *dest; |
216 | guint i; | 219 | guint i, len; |
217 | 220 | ||
218 | dest = g_array_sized_new (FALSE, TRUE, sizeof (GValue), src->len); | 221 | len = src->len; |
219 | g_array_set_size (dest, src->len); | 222 | dest = g_array_sized_new (FALSE, TRUE, sizeof (GValue), len); |
220 | for (i = 0; i < src->len; i++) { | 223 | g_array_set_size (dest, len); |
224 | for (i = 0; i < len; i++) { | ||
221 | gst_value_init_and_copy (&g_array_index (dest, GValue, i), | 225 | gst_value_init_and_copy (&g_array_index (dest, GValue, i), |
222 | &g_array_index (src, GValue, i)); | 226 | &g_array_index (src, GValue, i)); |
223 | } | 227 | } |
@@ -235,11 +239,12 @@ gst_value_copy_list_or_array (const GValue * src_value, GValue * dest_value) | |||
235 | static void | 239 | static void |
236 | gst_value_free_list_or_array (GValue * value) | 240 | gst_value_free_list_or_array (GValue * value) |
237 | { | 241 | { |
238 | guint i; | 242 | guint i, len; |
239 | GArray *src = (GArray *) value->data[0].v_pointer; | 243 | GArray *src = (GArray *) value->data[0].v_pointer; |
244 | len = src->len; | ||
240 | 245 | ||
241 | if ((value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS) == 0) { | 246 | if ((value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS) == 0) { |
242 | for (i = 0; i < src->len; i++) { | 247 | for (i = 0; i < len; i++) { |
243 | g_value_unset (&g_array_index (src, GValue, i)); | 248 | g_value_unset (&g_array_index (src, GValue, i)); |
244 | } | 249 | } |
245 | g_array_free (src, TRUE); | 250 | g_array_free (src, TRUE); |
@@ -554,13 +559,14 @@ gst_value_compare_array (const GValue * value1, const GValue * value2) | |||
554 | guint i; | 559 | guint i; |
555 | GArray *array1 = value1->data[0].v_pointer; | 560 | GArray *array1 = value1->data[0].v_pointer; |
556 | GArray *array2 = value2->data[0].v_pointer; | 561 | GArray *array2 = value2->data[0].v_pointer; |
562 | guint len = array1->len; | ||
557 | GValue *v1; | 563 | GValue *v1; |
558 | GValue *v2; | 564 | GValue *v2; |
559 | 565 | ||
560 | if (array1->len != array2->len) | 566 | if (len != array2->len) |
561 | return GST_VALUE_UNORDERED; | 567 | return GST_VALUE_UNORDERED; |
562 | 568 | ||
563 | for (i = 0; i < array1->len; i++) { | 569 | for (i = 0; i < len; i++) { |
564 | v1 = &g_array_index (array1, GValue, i); | 570 | v1 = &g_array_index (array1, GValue, i); |
565 | v2 = &g_array_index (array2, GValue, i); | 571 | v2 = &g_array_index (array2, GValue, i); |
566 | if (gst_value_compare (v1, v2) != GST_VALUE_EQUAL) | 572 | if (gst_value_compare (v1, v2) != GST_VALUE_EQUAL) |
@@ -2839,8 +2845,10 @@ gst_value_get_compare_func (const GValue * value1) | |||
2839 | 2845 | ||
2840 | /* slower checks */ | 2846 | /* slower checks */ |
2841 | if (G_UNLIKELY (!best || !best->compare)) { | 2847 | if (G_UNLIKELY (!best || !best->compare)) { |
2848 | guint len = gst_value_table->len; | ||
2849 | |||
2842 | best = NULL; | 2850 | best = NULL; |
2843 | for (i = 0; i < gst_value_table->len; i++) { | 2851 | for (i = 0; i < len; i++) { |
2844 | table = &g_array_index (gst_value_table, GstValueTable, i); | 2852 | table = &g_array_index (gst_value_table, GstValueTable, i); |
2845 | if (table->compare && g_type_is_a (type1, table->type)) { | 2853 | if (table->compare && g_type_is_a (type1, table->type)) { |
2846 | if (!best || g_type_is_a (table->type, best->type)) | 2854 | if (!best || g_type_is_a (table->type, best->type)) |
@@ -2949,9 +2957,11 @@ gboolean | |||
2949 | gst_value_can_union (const GValue * value1, const GValue * value2) | 2957 | gst_value_can_union (const GValue * value1, const GValue * value2) |
2950 | { | 2958 | { |
2951 | GstValueUnionInfo *union_info; | 2959 | GstValueUnionInfo *union_info; |
2952 | guint i; | 2960 | guint i, len; |
2961 | |||
2962 | len = gst_value_union_funcs->len; | ||
2953 | 2963 | ||
2954 | for (i = 0; i < gst_value_union_funcs->len; i++) { | 2964 | for (i = 0; i < len; i++) { |
2955 | union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i); | 2965 | union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i); |
2956 | if (union_info->type1 == G_VALUE_TYPE (value1) && | 2966 | if (union_info->type1 == G_VALUE_TYPE (value1) && |
2957 | union_info->type2 == G_VALUE_TYPE (value2)) | 2967 | union_info->type2 == G_VALUE_TYPE (value2)) |
@@ -2979,9 +2989,11 @@ gboolean | |||
2979 | gst_value_union (GValue * dest, const GValue * value1, const GValue * value2) | 2989 | gst_value_union (GValue * dest, const GValue * value1, const GValue * value2) |
2980 | { | 2990 | { |
2981 | GstValueUnionInfo *union_info; | 2991 | GstValueUnionInfo *union_info; |
2982 | guint i; | 2992 | guint i, len; |
2993 | |||
2994 | len = gst_value_union_funcs->len; | ||
2983 | 2995 | ||
2984 | for (i = 0; i < gst_value_union_funcs->len; i++) { | 2996 | for (i = 0; i < len; i++) { |
2985 | union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i); | 2997 | union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i); |
2986 | if (union_info->type1 == G_VALUE_TYPE (value1) && | 2998 | if (union_info->type1 == G_VALUE_TYPE (value1) && |
2987 | union_info->type2 == G_VALUE_TYPE (value2)) { | 2999 | union_info->type2 == G_VALUE_TYPE (value2)) { |
@@ -3044,7 +3056,7 @@ gboolean | |||
3044 | gst_value_can_intersect (const GValue * value1, const GValue * value2) | 3056 | gst_value_can_intersect (const GValue * value1, const GValue * value2) |
3045 | { | 3057 | { |
3046 | GstValueIntersectInfo *intersect_info; | 3058 | GstValueIntersectInfo *intersect_info; |
3047 | guint i; | 3059 | guint i, len; |
3048 | GType ltype, type1, type2; | 3060 | GType ltype, type1, type2; |
3049 | 3061 | ||
3050 | ltype = gst_value_list_get_type (); | 3062 | ltype = gst_value_list_get_type (); |
@@ -3056,7 +3068,8 @@ gst_value_can_intersect (const GValue * value1, const GValue * value2) | |||
3056 | type1 = G_VALUE_TYPE (value1); | 3068 | type1 = G_VALUE_TYPE (value1); |
3057 | type2 = G_VALUE_TYPE (value2); | 3069 | type2 = G_VALUE_TYPE (value2); |
3058 | 3070 | ||
3059 | for (i = 0; i < gst_value_intersect_funcs->len; i++) { | 3071 | len = gst_value_intersect_funcs->len; |
3072 | for (i = 0; i < len; i++) { | ||
3060 | intersect_info = &g_array_index (gst_value_intersect_funcs, | 3073 | intersect_info = &g_array_index (gst_value_intersect_funcs, |
3061 | GstValueIntersectInfo, i); | 3074 | GstValueIntersectInfo, i); |
3062 | if (intersect_info->type1 == intersect_info->type2 && | 3075 | if (intersect_info->type1 == intersect_info->type2 && |
@@ -3086,7 +3099,7 @@ gst_value_intersect (GValue * dest, const GValue * value1, | |||
3086 | const GValue * value2) | 3099 | const GValue * value2) |
3087 | { | 3100 | { |
3088 | GstValueIntersectInfo *intersect_info; | 3101 | GstValueIntersectInfo *intersect_info; |
3089 | guint i; | 3102 | guint i, len; |
3090 | GType ltype, type1, type2; | 3103 | GType ltype, type1, type2; |
3091 | 3104 | ||
3092 | ltype = gst_value_list_get_type (); | 3105 | ltype = gst_value_list_get_type (); |
@@ -3105,7 +3118,8 @@ gst_value_intersect (GValue * dest, const GValue * value1, | |||
3105 | type1 = G_VALUE_TYPE (value1); | 3118 | type1 = G_VALUE_TYPE (value1); |
3106 | type2 = G_VALUE_TYPE (value2); | 3119 | type2 = G_VALUE_TYPE (value2); |
3107 | 3120 | ||
3108 | for (i = 0; i < gst_value_intersect_funcs->len; i++) { | 3121 | len = gst_value_intersect_funcs->len; |
3122 | for (i = 0; i < len; i++) { | ||
3109 | intersect_info = &g_array_index (gst_value_intersect_funcs, | 3123 | intersect_info = &g_array_index (gst_value_intersect_funcs, |
3110 | GstValueIntersectInfo, i); | 3124 | GstValueIntersectInfo, i); |
3111 | if (intersect_info->type1 == type1 && intersect_info->type2 == type2) { | 3125 | if (intersect_info->type1 == type1 && intersect_info->type2 == type2) { |
@@ -3164,7 +3178,7 @@ gst_value_subtract (GValue * dest, const GValue * minuend, | |||
3164 | const GValue * subtrahend) | 3178 | const GValue * subtrahend) |
3165 | { | 3179 | { |
3166 | GstValueSubtractInfo *info; | 3180 | GstValueSubtractInfo *info; |
3167 | guint i; | 3181 | guint i, len; |
3168 | GType ltype, mtype, stype; | 3182 | GType ltype, mtype, stype; |
3169 | 3183 | ||
3170 | ltype = gst_value_list_get_type (); | 3184 | ltype = gst_value_list_get_type (); |
@@ -3178,7 +3192,8 @@ gst_value_subtract (GValue * dest, const GValue * minuend, | |||
3178 | mtype = G_VALUE_TYPE (minuend); | 3192 | mtype = G_VALUE_TYPE (minuend); |
3179 | stype = G_VALUE_TYPE (subtrahend); | 3193 | stype = G_VALUE_TYPE (subtrahend); |
3180 | 3194 | ||
3181 | for (i = 0; i < gst_value_subtract_funcs->len; i++) { | 3195 | len = gst_value_subtract_funcs->len; |
3196 | for (i = 0; i < len; i++) { | ||
3182 | info = &g_array_index (gst_value_subtract_funcs, GstValueSubtractInfo, i); | 3197 | info = &g_array_index (gst_value_subtract_funcs, GstValueSubtractInfo, i); |
3183 | if (info->minuend == mtype && info->subtrahend == stype) { | 3198 | if (info->minuend == mtype && info->subtrahend == stype) { |
3184 | return info->func (dest, minuend, subtrahend); | 3199 | return info->func (dest, minuend, subtrahend); |
@@ -3220,7 +3235,7 @@ gboolean | |||
3220 | gst_value_can_subtract (const GValue * minuend, const GValue * subtrahend) | 3235 | gst_value_can_subtract (const GValue * minuend, const GValue * subtrahend) |
3221 | { | 3236 | { |
3222 | GstValueSubtractInfo *info; | 3237 | GstValueSubtractInfo *info; |
3223 | guint i; | 3238 | guint i, len; |
3224 | GType ltype, mtype, stype; | 3239 | GType ltype, mtype, stype; |
3225 | 3240 | ||
3226 | ltype = gst_value_list_get_type (); | 3241 | ltype = gst_value_list_get_type (); |
@@ -3232,7 +3247,8 @@ gst_value_can_subtract (const GValue * minuend, const GValue * subtrahend) | |||
3232 | mtype = G_VALUE_TYPE (minuend); | 3247 | mtype = G_VALUE_TYPE (minuend); |
3233 | stype = G_VALUE_TYPE (subtrahend); | 3248 | stype = G_VALUE_TYPE (subtrahend); |
3234 | 3249 | ||
3235 | for (i = 0; i < gst_value_subtract_funcs->len; i++) { | 3250 | len = gst_value_subtract_funcs->len; |
3251 | for (i = 0; i < len; i++) { | ||
3236 | info = &g_array_index (gst_value_subtract_funcs, GstValueSubtractInfo, i); | 3252 | info = &g_array_index (gst_value_subtract_funcs, GstValueSubtractInfo, i); |
3237 | if (info->minuend == mtype && info->subtrahend == stype) | 3253 | if (info->minuend == mtype && info->subtrahend == stype) |
3238 | return TRUE; | 3254 | return TRUE; |
@@ -3321,7 +3337,7 @@ gst_value_init_and_copy (GValue * dest, const GValue * src) | |||
3321 | gchar * | 3337 | gchar * |
3322 | gst_value_serialize (const GValue * value) | 3338 | gst_value_serialize (const GValue * value) |
3323 | { | 3339 | { |
3324 | guint i; | 3340 | guint i, len; |
3325 | GValue s_val = { 0 }; | 3341 | GValue s_val = { 0 }; |
3326 | GstValueTable *table, *best; | 3342 | GstValueTable *table, *best; |
3327 | char *s; | 3343 | char *s; |
@@ -3334,8 +3350,9 @@ gst_value_serialize (const GValue * value) | |||
3334 | best = gst_value_hash_lookup_type (type); | 3350 | best = gst_value_hash_lookup_type (type); |
3335 | 3351 | ||
3336 | if (G_UNLIKELY (!best || !best->serialize)) { | 3352 | if (G_UNLIKELY (!best || !best->serialize)) { |
3353 | len = gst_value_table->len; | ||
3337 | best = NULL; | 3354 | best = NULL; |
3338 | for (i = 0; i < gst_value_table->len; i++) { | 3355 | for (i = 0; i < len; i++) { |
3339 | table = &g_array_index (gst_value_table, GstValueTable, i); | 3356 | table = &g_array_index (gst_value_table, GstValueTable, i); |
3340 | if (table->serialize && g_type_is_a (type, table->type)) { | 3357 | if (table->serialize && g_type_is_a (type, table->type)) { |
3341 | if (!best || g_type_is_a (table->type, best->type)) | 3358 | if (!best || g_type_is_a (table->type, best->type)) |
@@ -3371,7 +3388,7 @@ gboolean | |||
3371 | gst_value_deserialize (GValue * dest, const gchar * src) | 3388 | gst_value_deserialize (GValue * dest, const gchar * src) |
3372 | { | 3389 | { |
3373 | GstValueTable *table, *best; | 3390 | GstValueTable *table, *best; |
3374 | guint i; | 3391 | guint i, len; |
3375 | GType type; | 3392 | GType type; |
3376 | 3393 | ||
3377 | g_return_val_if_fail (src != NULL, FALSE); | 3394 | g_return_val_if_fail (src != NULL, FALSE); |
@@ -3381,8 +3398,9 @@ gst_value_deserialize (GValue * dest, const gchar * src) | |||
3381 | 3398 | ||
3382 | best = gst_value_hash_lookup_type (type); | 3399 | best = gst_value_hash_lookup_type (type); |
3383 | if (G_UNLIKELY (!best || !best->deserialize)) { | 3400 | if (G_UNLIKELY (!best || !best->deserialize)) { |
3401 | len = gst_value_table->len; | ||
3384 | best = NULL; | 3402 | best = NULL; |
3385 | for (i = 0; i < gst_value_table->len; i++) { | 3403 | for (i = 0; i < len; i++) { |
3386 | table = &g_array_index (gst_value_table, GstValueTable, i); | 3404 | table = &g_array_index (gst_value_table, GstValueTable, i); |
3387 | if (table->deserialize && g_type_is_a (type, table->type)) { | 3405 | if (table->deserialize && g_type_is_a (type, table->type)) { |
3388 | if (!best || g_type_is_a (table->type, best->type)) | 3406 | if (!best || g_type_is_a (table->type, best->type)) |