diff options
author | Edward Hervey <bilboed@bilboed.com> | 2009-06-29 11:23:31 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2009-06-30 16:29:58 +0200 |
commit | 3c21f2d86c72fa2d8c8d6b8d5087599497c2673c (patch) | |
tree | 8afb91c8faa9d7cfd09576cfc9d05328e2ff4643 | |
parent | 923913984e3b6448c9b9bae6d17a52a6f7a33646 (diff) |
Spread branch prediction macros.
These are based on profiling several playback scenarios using playbin2.
-rw-r--r-- | gst/gstcaps.c | 38 | ||||
-rw-r--r-- | gst/gstpad.c | 2 | ||||
-rw-r--r-- | gst/gstregistry.c | 5 | ||||
-rw-r--r-- | gst/gstregistrybinary.c | 27 | ||||
-rw-r--r-- | gst/gststructure.c | 37 |
5 files changed, 56 insertions, 53 deletions
diff --git a/gst/gstcaps.c b/gst/gstcaps.c index ba33ed9fa2..958c7c5885 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c | |||
@@ -509,7 +509,7 @@ gst_structure_is_equal_foreach (GQuark field_id, const GValue * val2, | |||
509 | GstStructure *struct1 = (GstStructure *) data; | 509 | GstStructure *struct1 = (GstStructure *) data; |
510 | const GValue *val1 = gst_structure_id_get_value (struct1, field_id); | 510 | const GValue *val1 = gst_structure_id_get_value (struct1, field_id); |
511 | 511 | ||
512 | if (val1 == NULL) | 512 | if (G_UNLIKELY (val1 == NULL)) |
513 | return FALSE; | 513 | return FALSE; |
514 | if (gst_value_compare (val1, val2) == GST_VALUE_EQUAL) { | 514 | if (gst_value_compare (val1, val2) == GST_VALUE_EQUAL) { |
515 | return TRUE; | 515 | return TRUE; |
@@ -601,7 +601,7 @@ gst_caps_append (GstCaps * caps1, GstCaps * caps2) | |||
601 | #ifdef USE_POISONING | 601 | #ifdef USE_POISONING |
602 | CAPS_POISON (caps2); | 602 | CAPS_POISON (caps2); |
603 | #endif | 603 | #endif |
604 | if (gst_caps_is_any (caps1) || gst_caps_is_any (caps2)) { | 604 | if (G_UNLIKELY (gst_caps_is_any (caps1) || gst_caps_is_any (caps2))) { |
605 | /* FIXME: this leaks */ | 605 | /* FIXME: this leaks */ |
606 | caps1->flags |= GST_CAPS_FLAGS_ANY; | 606 | caps1->flags |= GST_CAPS_FLAGS_ANY; |
607 | for (i = caps2->structs->len - 1; i >= 0; i--) { | 607 | for (i = caps2->structs->len - 1; i >= 0; i--) { |
@@ -643,12 +643,12 @@ gst_caps_merge (GstCaps * caps1, GstCaps * caps2) | |||
643 | #ifdef USE_POISONING | 643 | #ifdef USE_POISONING |
644 | CAPS_POISON (caps2); | 644 | CAPS_POISON (caps2); |
645 | #endif | 645 | #endif |
646 | if (gst_caps_is_any (caps1)) { | 646 | if (G_UNLIKELY (gst_caps_is_any (caps1))) { |
647 | for (i = caps2->structs->len - 1; i >= 0; i--) { | 647 | for (i = caps2->structs->len - 1; i >= 0; i--) { |
648 | structure = gst_caps_remove_and_get_structure (caps2, i); | 648 | structure = gst_caps_remove_and_get_structure (caps2, i); |
649 | gst_structure_free (structure); | 649 | gst_structure_free (structure); |
650 | } | 650 | } |
651 | } else if (gst_caps_is_any (caps2)) { | 651 | } else if (G_UNLIKELY (gst_caps_is_any (caps2))) { |
652 | caps1->flags |= GST_CAPS_FLAGS_ANY; | 652 | caps1->flags |= GST_CAPS_FLAGS_ANY; |
653 | for (i = caps1->structs->len - 1; i >= 0; i--) { | 653 | for (i = caps1->structs->len - 1; i >= 0; i--) { |
654 | structure = gst_caps_remove_and_get_structure (caps1, i); | 654 | structure = gst_caps_remove_and_get_structure (caps1, i); |
@@ -831,7 +831,7 @@ gst_caps_copy_nth (const GstCaps * caps, guint nth) | |||
831 | newcaps = gst_caps_new_empty (); | 831 | newcaps = gst_caps_new_empty (); |
832 | newcaps->flags = caps->flags; | 832 | newcaps->flags = caps->flags; |
833 | 833 | ||
834 | if (caps->structs->len > nth) { | 834 | if (G_LIKELY (caps->structs->len > nth)) { |
835 | structure = gst_caps_get_structure_unchecked (caps, nth); | 835 | structure = gst_caps_get_structure_unchecked (caps, nth); |
836 | gst_caps_append_structure (newcaps, gst_structure_copy (structure)); | 836 | gst_caps_append_structure (newcaps, gst_structure_copy (structure)); |
837 | } | 837 | } |
@@ -1083,15 +1083,15 @@ gst_caps_is_equal (const GstCaps * caps1, const GstCaps * caps2) | |||
1083 | * So there should be an assertion that caps1 and caps2 != NULL */ | 1083 | * So there should be an assertion that caps1 and caps2 != NULL */ |
1084 | 1084 | ||
1085 | /* NULL <-> NULL is allowed here */ | 1085 | /* NULL <-> NULL is allowed here */ |
1086 | if (caps1 == caps2) | 1086 | if (G_UNLIKELY (caps1 == caps2)) |
1087 | return TRUE; | 1087 | return TRUE; |
1088 | 1088 | ||
1089 | /* one of them NULL => they are different (can't be both NULL because | 1089 | /* one of them NULL => they are different (can't be both NULL because |
1090 | * we checked that above) */ | 1090 | * we checked that above) */ |
1091 | if (caps1 == NULL || caps2 == NULL) | 1091 | if (G_UNLIKELY (caps1 == NULL || caps2 == NULL)) |
1092 | return FALSE; | 1092 | return FALSE; |
1093 | 1093 | ||
1094 | if (gst_caps_is_fixed (caps1) && gst_caps_is_fixed (caps2)) | 1094 | if (G_UNLIKELY (gst_caps_is_fixed (caps1) && gst_caps_is_fixed (caps2))) |
1095 | return gst_caps_is_equal_fixed (caps1, caps2); | 1095 | return gst_caps_is_equal_fixed (caps1, caps2); |
1096 | 1096 | ||
1097 | return gst_caps_is_subset (caps1, caps2) && gst_caps_is_subset (caps2, caps1); | 1097 | return gst_caps_is_subset (caps1, caps2) && gst_caps_is_subset (caps2, caps1); |
@@ -1113,7 +1113,7 @@ gst_caps_structure_intersect_field (GQuark id, const GValue * val1, | |||
1113 | GValue dest_value = { 0 }; | 1113 | GValue dest_value = { 0 }; |
1114 | const GValue *val2 = gst_structure_id_get_value (idata->intersect, id); | 1114 | const GValue *val2 = gst_structure_id_get_value (idata->intersect, id); |
1115 | 1115 | ||
1116 | if (val2 == NULL) { | 1116 | if (G_UNLIKELY (val2 == NULL)) { |
1117 | gst_structure_id_set_value (idata->dest, id, val1); | 1117 | gst_structure_id_set_value (idata->dest, id, val1); |
1118 | } else if (idata->first_run) { | 1118 | } else if (idata->first_run) { |
1119 | if (gst_value_intersect (&dest_value, val1, val2)) { | 1119 | if (gst_value_intersect (&dest_value, val1, val2)) { |
@@ -1136,20 +1136,20 @@ gst_caps_structure_intersect (const GstStructure * struct1, | |||
1136 | g_return_val_if_fail (struct1 != NULL, NULL); | 1136 | g_return_val_if_fail (struct1 != NULL, NULL); |
1137 | g_return_val_if_fail (struct2 != NULL, NULL); | 1137 | g_return_val_if_fail (struct2 != NULL, NULL); |
1138 | 1138 | ||
1139 | if (struct1->name != struct2->name) | 1139 | if (G_UNLIKELY (struct1->name != struct2->name)) |
1140 | return NULL; | 1140 | return NULL; |
1141 | 1141 | ||
1142 | data.dest = gst_structure_id_empty_new (struct1->name); | 1142 | data.dest = gst_structure_id_empty_new (struct1->name); |
1143 | data.intersect = struct2; | 1143 | data.intersect = struct2; |
1144 | data.first_run = TRUE; | 1144 | data.first_run = TRUE; |
1145 | if (!gst_structure_foreach ((GstStructure *) struct1, | 1145 | if (G_UNLIKELY (!gst_structure_foreach ((GstStructure *) struct1, |
1146 | gst_caps_structure_intersect_field, &data)) | 1146 | gst_caps_structure_intersect_field, &data))) |
1147 | goto error; | 1147 | goto error; |
1148 | 1148 | ||
1149 | data.intersect = struct1; | 1149 | data.intersect = struct1; |
1150 | data.first_run = FALSE; | 1150 | data.first_run = FALSE; |
1151 | if (!gst_structure_foreach ((GstStructure *) struct2, | 1151 | if (G_UNLIKELY (!gst_structure_foreach ((GstStructure *) struct2, |
1152 | gst_caps_structure_intersect_field, &data)) | 1152 | gst_caps_structure_intersect_field, &data))) |
1153 | goto error; | 1153 | goto error; |
1154 | 1154 | ||
1155 | return data.dest; | 1155 | return data.dest; |
@@ -1226,17 +1226,17 @@ gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2) | |||
1226 | g_return_val_if_fail (GST_IS_CAPS (caps2), NULL); | 1226 | g_return_val_if_fail (GST_IS_CAPS (caps2), NULL); |
1227 | 1227 | ||
1228 | /* caps are exactly the same pointers, just copy one caps */ | 1228 | /* caps are exactly the same pointers, just copy one caps */ |
1229 | if (caps1 == caps2) | 1229 | if (G_UNLIKELY (caps1 == caps2)) |
1230 | return gst_caps_copy (caps1); | 1230 | return gst_caps_copy (caps1); |
1231 | 1231 | ||
1232 | /* empty caps on either side, return empty */ | 1232 | /* empty caps on either side, return empty */ |
1233 | if (gst_caps_is_empty (caps1) || gst_caps_is_empty (caps2)) | 1233 | if (G_UNLIKELY (gst_caps_is_empty (caps1) || gst_caps_is_empty (caps2))) |
1234 | return gst_caps_new_empty (); | 1234 | return gst_caps_new_empty (); |
1235 | 1235 | ||
1236 | /* one of the caps is any, just copy the other caps */ | 1236 | /* one of the caps is any, just copy the other caps */ |
1237 | if (gst_caps_is_any (caps1)) | 1237 | if (G_UNLIKELY (gst_caps_is_any (caps1))) |
1238 | return gst_caps_copy (caps2); | 1238 | return gst_caps_copy (caps2); |
1239 | if (gst_caps_is_any (caps2)) | 1239 | if (G_UNLIKELY (gst_caps_is_any (caps2))) |
1240 | return gst_caps_copy (caps1); | 1240 | return gst_caps_copy (caps1); |
1241 | 1241 | ||
1242 | dest = gst_caps_new_empty (); | 1242 | dest = gst_caps_new_empty (); |
@@ -1277,7 +1277,7 @@ gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2) | |||
1277 | gst_caps_append_structure (dest, istruct); | 1277 | gst_caps_append_structure (dest, istruct); |
1278 | /* move down left */ | 1278 | /* move down left */ |
1279 | k++; | 1279 | k++; |
1280 | if (j == 0) | 1280 | if (G_UNLIKELY (j == 0)) |
1281 | break; /* so we don't roll back to G_MAXUINT */ | 1281 | break; /* so we don't roll back to G_MAXUINT */ |
1282 | j--; | 1282 | j--; |
1283 | } | 1283 | } |
diff --git a/gst/gstpad.c b/gst/gstpad.c index 20069f6957..cbcd25cbf3 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c | |||
@@ -1766,7 +1766,7 @@ gst_pad_link_check_compatible_unlocked (GstPad * src, GstPad * sink) | |||
1766 | 1766 | ||
1767 | /* if we have caps on both pads we can check the intersection. If one | 1767 | /* if we have caps on both pads we can check the intersection. If one |
1768 | * of the caps is NULL, we return TRUE. */ | 1768 | * of the caps is NULL, we return TRUE. */ |
1769 | if (srccaps == NULL || sinkcaps == NULL) { | 1769 | if (G_UNLIKELY (srccaps == NULL || sinkcaps == NULL)) { |
1770 | if (srccaps) | 1770 | if (srccaps) |
1771 | gst_caps_unref (srccaps); | 1771 | gst_caps_unref (srccaps); |
1772 | if (sinkcaps) | 1772 | if (sinkcaps) |
diff --git a/gst/gstregistry.c b/gst/gstregistry.c index 67e97fecf2..88062d250b 100644 --- a/gst/gstregistry.c +++ b/gst/gstregistry.c | |||
@@ -380,7 +380,7 @@ gst_registry_remove_features_for_plugin_unlocked (GstRegistry * registry, | |||
380 | GList *next = g_list_next (f); | 380 | GList *next = g_list_next (f); |
381 | GstPluginFeature *feature = f->data; | 381 | GstPluginFeature *feature = f->data; |
382 | 382 | ||
383 | if (feature && !strcmp (feature->plugin_name, name)) { | 383 | if (G_UNLIKELY (feature && !strcmp (feature->plugin_name, name))) { |
384 | GST_DEBUG_OBJECT (registry, "removing feature %p (%s) for plugin %s", | 384 | GST_DEBUG_OBJECT (registry, "removing feature %p (%s) for plugin %s", |
385 | feature, gst_plugin_feature_get_name (feature), name); | 385 | feature, gst_plugin_feature_get_name (feature), name); |
386 | 386 | ||
@@ -755,7 +755,8 @@ gst_registry_lookup_locked (GstRegistry * registry, const char *filename) | |||
755 | /* FIXME: use GTree speed up lookups */ | 755 | /* FIXME: use GTree speed up lookups */ |
756 | for (g = registry->plugins; g; g = g_list_next (g)) { | 756 | for (g = registry->plugins; g; g = g_list_next (g)) { |
757 | plugin = GST_PLUGIN_CAST (g->data); | 757 | plugin = GST_PLUGIN_CAST (g->data); |
758 | if (plugin->basename && strcmp (basename, plugin->basename) == 0) { | 758 | if (G_UNLIKELY (plugin->basename |
759 | && strcmp (basename, plugin->basename) == 0)) { | ||
759 | g_free (basename); | 760 | g_free (basename); |
760 | return plugin; | 761 | return plugin; |
761 | } | 762 | } |
diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c index c24e191c0e..222e749870 100644 --- a/gst/gstregistrybinary.c +++ b/gst/gstregistrybinary.c | |||
@@ -76,12 +76,12 @@ _strnlen (const gchar * str, gint maxlen) | |||
76 | { | 76 | { |
77 | gint len = 0; | 77 | gint len = 0; |
78 | 78 | ||
79 | if (len == maxlen) | 79 | if (G_UNLIKELY (len == maxlen)) |
80 | return -1; | 80 | return -1; |
81 | 81 | ||
82 | while (*str++ != '\0') { | 82 | while (*str++ != '\0') { |
83 | len++; | 83 | len++; |
84 | if (len == maxlen) | 84 | if (G_UNLIKELY (len == maxlen)) |
85 | return -1; | 85 | return -1; |
86 | } | 86 | } |
87 | return len; | 87 | return len; |
@@ -913,26 +913,26 @@ gst_registry_binary_load_feature (GstRegistry * registry, gchar ** in, | |||
913 | /* unpack plugin feature strings */ | 913 | /* unpack plugin feature strings */ |
914 | unpack_string (*in, type_name, end, fail); | 914 | unpack_string (*in, type_name, end, fail); |
915 | 915 | ||
916 | if (!type_name) { | 916 | if (G_UNLIKELY (!type_name)) { |
917 | GST_ERROR ("No feature type name"); | 917 | GST_ERROR ("No feature type name"); |
918 | return FALSE; | 918 | return FALSE; |
919 | } | 919 | } |
920 | 920 | ||
921 | GST_DEBUG ("Plugin '%s' feature typename : '%s'", plugin_name, type_name); | 921 | GST_DEBUG ("Plugin '%s' feature typename : '%s'", plugin_name, type_name); |
922 | 922 | ||
923 | if (!(type = g_type_from_name (type_name))) { | 923 | if (G_UNLIKELY (!(type = g_type_from_name (type_name)))) { |
924 | GST_ERROR ("Unknown type from typename '%s' for plugin '%s'", type_name, | 924 | GST_ERROR ("Unknown type from typename '%s' for plugin '%s'", type_name, |
925 | plugin_name); | 925 | plugin_name); |
926 | g_free (type_name); | 926 | g_free (type_name); |
927 | return FALSE; | 927 | return FALSE; |
928 | } | 928 | } |
929 | if ((feature = g_object_new (type, NULL)) == NULL) { | 929 | if (G_UNLIKELY ((feature = g_object_new (type, NULL)) == NULL)) { |
930 | GST_ERROR ("Can't create feature from type"); | 930 | GST_ERROR ("Can't create feature from type"); |
931 | g_free (type_name); | 931 | g_free (type_name); |
932 | return FALSE; | 932 | return FALSE; |
933 | } | 933 | } |
934 | 934 | ||
935 | if (!GST_IS_PLUGIN_FEATURE (feature)) { | 935 | if (G_UNLIKELY (!GST_IS_PLUGIN_FEATURE (feature))) { |
936 | GST_ERROR ("typename : '%s' is not a plugin feature", type_name); | 936 | GST_ERROR ("typename : '%s' is not a plugin feature", type_name); |
937 | goto fail; | 937 | goto fail; |
938 | } | 938 | } |
@@ -1178,7 +1178,7 @@ gst_registry_binary_load_plugin (GstRegistry * registry, gchar ** in, | |||
1178 | 1178 | ||
1179 | /* Load external plugin dependencies */ | 1179 | /* Load external plugin dependencies */ |
1180 | for (i = 0; i < pe->n_deps; ++i) { | 1180 | for (i = 0; i < pe->n_deps; ++i) { |
1181 | if (!gst_registry_binary_load_plugin_dep (plugin, in, end)) { | 1181 | if (G_UNLIKELY (!gst_registry_binary_load_plugin_dep (plugin, in, end))) { |
1182 | GST_ERROR_OBJECT (plugin, "Could not read external plugin dependency"); | 1182 | GST_ERROR_OBJECT (plugin, "Could not read external plugin dependency"); |
1183 | gst_registry_remove_plugin (registry, plugin); | 1183 | gst_registry_remove_plugin (registry, plugin); |
1184 | goto fail; | 1184 | goto fail; |
@@ -1228,7 +1228,7 @@ gst_registry_binary_read_cache (GstRegistry * registry, const char *location) | |||
1228 | #endif | 1228 | #endif |
1229 | 1229 | ||
1230 | mapped = g_mapped_file_new (location, FALSE, &err); | 1230 | mapped = g_mapped_file_new (location, FALSE, &err); |
1231 | if (err != NULL) { | 1231 | if (G_UNLIKELY (err != NULL)) { |
1232 | GST_INFO ("Unable to mmap file %s : %s", location, err->message); | 1232 | GST_INFO ("Unable to mmap file %s : %s", location, err->message); |
1233 | g_error_free (err); | 1233 | g_error_free (err); |
1234 | err = NULL; | 1234 | err = NULL; |
@@ -1243,7 +1243,7 @@ gst_registry_binary_read_cache (GstRegistry * registry, const char *location) | |||
1243 | return FALSE; | 1243 | return FALSE; |
1244 | } | 1244 | } |
1245 | } else { | 1245 | } else { |
1246 | if ((contents = g_mapped_file_get_contents (mapped)) == NULL) { | 1246 | if (G_UNLIKELY ((contents = g_mapped_file_get_contents (mapped)) == NULL)) { |
1247 | GST_ERROR ("Can't load file %s : %s", location, g_strerror (errno)); | 1247 | GST_ERROR ("Can't load file %s : %s", location, g_strerror (errno)); |
1248 | goto Error; | 1248 | goto Error; |
1249 | } | 1249 | } |
@@ -1254,13 +1254,14 @@ gst_registry_binary_read_cache (GstRegistry * registry, const char *location) | |||
1254 | /* in is a cursor pointer, we initialize it with the begin of registry and is updated on each read */ | 1254 | /* in is a cursor pointer, we initialize it with the begin of registry and is updated on each read */ |
1255 | in = contents; | 1255 | in = contents; |
1256 | GST_DEBUG ("File data at address %p", in); | 1256 | GST_DEBUG ("File data at address %p", in); |
1257 | if (size < sizeof (GstBinaryRegistryMagic)) { | 1257 | if (G_UNLIKELY (size < sizeof (GstBinaryRegistryMagic))) { |
1258 | GST_ERROR ("No or broken registry header"); | 1258 | GST_ERROR ("No or broken registry header"); |
1259 | goto Error; | 1259 | goto Error; |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | /* check if header is valid */ | 1262 | /* check if header is valid */ |
1263 | if ((check_magic_result = gst_registry_binary_check_magic (&in, size)) < 0) { | 1263 | if (G_UNLIKELY ((check_magic_result = |
1264 | gst_registry_binary_check_magic (&in, size)) < 0)) { | ||
1264 | 1265 | ||
1265 | if (check_magic_result == -1) | 1266 | if (check_magic_result == -1) |
1266 | GST_ERROR | 1267 | GST_ERROR |
@@ -1270,8 +1271,8 @@ gst_registry_binary_read_cache (GstRegistry * registry, const char *location) | |||
1270 | } | 1271 | } |
1271 | 1272 | ||
1272 | /* check if there are plugins in the file */ | 1273 | /* check if there are plugins in the file */ |
1273 | if (!(((gsize) in + sizeof (GstBinaryPluginElement)) < | 1274 | if (G_UNLIKELY (!(((gsize) in + sizeof (GstBinaryPluginElement)) < |
1274 | (gsize) contents + size)) { | 1275 | (gsize) contents + size))) { |
1275 | GST_INFO ("No binary plugins structure to read"); | 1276 | GST_INFO ("No binary plugins structure to read"); |
1276 | /* empty file, this is not an error */ | 1277 | /* empty file, this is not an error */ |
1277 | } else { | 1278 | } else { |
diff --git a/gst/gststructure.c b/gst/gststructure.c index 2c8fa95b3b..2d512b6ea3 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c | |||
@@ -155,7 +155,7 @@ gst_structure_validate_name (const gchar * name) | |||
155 | g_return_val_if_fail (name != NULL, FALSE); | 155 | g_return_val_if_fail (name != NULL, FALSE); |
156 | 156 | ||
157 | /* FIXME 0.11: use g_ascii_isalpha() */ | 157 | /* FIXME 0.11: use g_ascii_isalpha() */ |
158 | if (!g_ascii_isalnum (*name)) { | 158 | if (G_UNLIKELY (!g_ascii_isalnum (*name))) { |
159 | GST_WARNING ("Invalid character '%c' at offset 0 in structure name: %s", | 159 | GST_WARNING ("Invalid character '%c' at offset 0 in structure name: %s", |
160 | *name, name); | 160 | *name, name); |
161 | return FALSE; | 161 | return FALSE; |
@@ -166,7 +166,7 @@ gst_structure_validate_name (const gchar * name) | |||
166 | s = &name[1]; | 166 | s = &name[1]; |
167 | while (*s && (g_ascii_isalnum (*s) || strchr ("/-_.:+ ", *s) != NULL)) | 167 | while (*s && (g_ascii_isalnum (*s) || strchr ("/-_.:+ ", *s) != NULL)) |
168 | s++; | 168 | s++; |
169 | if (*s != '\0') { | 169 | if (G_UNLIKELY (*s != '\0')) { |
170 | GST_WARNING ("Invalid character '%c' at offset %lu in structure name: %s", | 170 | GST_WARNING ("Invalid character '%c' at offset %lu in structure name: %s", |
171 | *s, ((gulong) s - (gulong) name), name); | 171 | *s, ((gulong) s - (gulong) name), name); |
172 | return FALSE; | 172 | return FALSE; |
@@ -519,14 +519,14 @@ gst_structure_set_valist (GstStructure * structure, | |||
519 | 519 | ||
520 | type = va_arg (varargs, GType); | 520 | type = va_arg (varargs, GType); |
521 | 521 | ||
522 | if (type == G_TYPE_DATE) { | 522 | if (G_UNLIKELY (type == G_TYPE_DATE)) { |
523 | g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n"); | 523 | g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n"); |
524 | type = GST_TYPE_DATE; | 524 | type = GST_TYPE_DATE; |
525 | } | 525 | } |
526 | 526 | ||
527 | g_value_init (&field.value, type); | 527 | g_value_init (&field.value, type); |
528 | G_VALUE_COLLECT (&field.value, varargs, 0, &err); | 528 | G_VALUE_COLLECT (&field.value, varargs, 0, &err); |
529 | if (err) { | 529 | if (G_UNLIKELY (err)) { |
530 | g_critical ("%s", err); | 530 | g_critical ("%s", err); |
531 | return; | 531 | return; |
532 | } | 532 | } |
@@ -589,14 +589,14 @@ gst_structure_id_set_valist (GstStructure * structure, | |||
589 | 589 | ||
590 | type = va_arg (varargs, GType); | 590 | type = va_arg (varargs, GType); |
591 | 591 | ||
592 | if (type == G_TYPE_DATE) { | 592 | if (G_UNLIKELY (type == G_TYPE_DATE)) { |
593 | g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n"); | 593 | g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n"); |
594 | type = GST_TYPE_DATE; | 594 | type = GST_TYPE_DATE; |
595 | } | 595 | } |
596 | 596 | ||
597 | g_value_init (&field.value, type); | 597 | g_value_init (&field.value, type); |
598 | G_VALUE_COLLECT (&field.value, varargs, 0, &err); | 598 | G_VALUE_COLLECT (&field.value, varargs, 0, &err); |
599 | if (err) { | 599 | if (G_UNLIKELY (err)) { |
600 | g_critical ("%s", err); | 600 | g_critical ("%s", err); |
601 | return; | 601 | return; |
602 | } | 602 | } |
@@ -682,7 +682,7 @@ gst_structure_set_field (GstStructure * structure, GstStructureField * field) | |||
682 | for (i = 0; i < len; i++) { | 682 | for (i = 0; i < len; i++) { |
683 | f = GST_STRUCTURE_FIELD (structure, i); | 683 | f = GST_STRUCTURE_FIELD (structure, i); |
684 | 684 | ||
685 | if (f->name == field->name) { | 685 | if (G_UNLIKELY (f->name == field->name)) { |
686 | g_value_unset (&f->value); | 686 | g_value_unset (&f->value); |
687 | memcpy (f, field, sizeof (GstStructureField)); | 687 | memcpy (f, field, sizeof (GstStructureField)); |
688 | return; | 688 | return; |
@@ -706,7 +706,7 @@ gst_structure_id_get_field (const GstStructure * structure, GQuark field_id) | |||
706 | for (i = 0; i < len; i++) { | 706 | for (i = 0; i < len; i++) { |
707 | field = GST_STRUCTURE_FIELD (structure, i); | 707 | field = GST_STRUCTURE_FIELD (structure, i); |
708 | 708 | ||
709 | if (field->name == field_id) | 709 | if (G_UNLIKELY (field->name == field_id)) |
710 | return field; | 710 | return field; |
711 | } | 711 | } |
712 | 712 | ||
@@ -979,7 +979,7 @@ gst_structure_foreach (const GstStructure * structure, | |||
979 | field = GST_STRUCTURE_FIELD (structure, i); | 979 | field = GST_STRUCTURE_FIELD (structure, i); |
980 | 980 | ||
981 | ret = func (field->name, &field->value, user_data); | 981 | ret = func (field->name, &field->value, user_data); |
982 | if (!ret) | 982 | if (G_UNLIKELY (!ret)) |
983 | return FALSE; | 983 | return FALSE; |
984 | } | 984 | } |
985 | 985 | ||
@@ -1830,7 +1830,7 @@ gst_structure_parse_simple_string (gchar * str, gchar ** end) | |||
1830 | { | 1830 | { |
1831 | char *s = str; | 1831 | char *s = str; |
1832 | 1832 | ||
1833 | while (GST_ASCII_IS_STRING (*s)) { | 1833 | while (G_LIKELY (GST_ASCII_IS_STRING (*s))) { |
1834 | s++; | 1834 | s++; |
1835 | } | 1835 | } |
1836 | 1836 | ||
@@ -1853,14 +1853,14 @@ gst_structure_parse_field (gchar * str, | |||
1853 | while (g_ascii_isspace (*s) || (s[0] == '\\' && g_ascii_isspace (s[1]))) | 1853 | while (g_ascii_isspace (*s) || (s[0] == '\\' && g_ascii_isspace (s[1]))) |
1854 | s++; | 1854 | s++; |
1855 | name = s; | 1855 | name = s; |
1856 | if (!gst_structure_parse_simple_string (s, &name_end)) | 1856 | if (G_UNLIKELY (!gst_structure_parse_simple_string (s, &name_end))) |
1857 | return FALSE; | 1857 | return FALSE; |
1858 | 1858 | ||
1859 | s = name_end; | 1859 | s = name_end; |
1860 | while (g_ascii_isspace (*s) || (s[0] == '\\' && g_ascii_isspace (s[1]))) | 1860 | while (g_ascii_isspace (*s) || (s[0] == '\\' && g_ascii_isspace (s[1]))) |
1861 | s++; | 1861 | s++; |
1862 | 1862 | ||
1863 | if (*s != '=') | 1863 | if (G_UNLIKELY (*s != '=')) |
1864 | return FALSE; | 1864 | return FALSE; |
1865 | s++; | 1865 | s++; |
1866 | 1866 | ||
@@ -1869,7 +1869,8 @@ gst_structure_parse_field (gchar * str, | |||
1869 | field->name = g_quark_from_string (name); | 1869 | field->name = g_quark_from_string (name); |
1870 | *name_end = c; | 1870 | *name_end = c; |
1871 | 1871 | ||
1872 | if (!gst_structure_parse_value (s, &s, &field->value, G_TYPE_INVALID)) | 1872 | if (G_UNLIKELY (!gst_structure_parse_value (s, &s, &field->value, |
1873 | G_TYPE_INVALID))) | ||
1873 | return FALSE; | 1874 | return FALSE; |
1874 | 1875 | ||
1875 | *after = s; | 1876 | *after = s; |
@@ -1900,12 +1901,12 @@ gst_structure_parse_value (gchar * str, | |||
1900 | while (g_ascii_isspace (*s)) | 1901 | while (g_ascii_isspace (*s)) |
1901 | s++; | 1902 | s++; |
1902 | type_name = s; | 1903 | type_name = s; |
1903 | if (!gst_structure_parse_simple_string (s, &type_end)) | 1904 | if (G_UNLIKELY (!gst_structure_parse_simple_string (s, &type_end))) |
1904 | return FALSE; | 1905 | return FALSE; |
1905 | s = type_end; | 1906 | s = type_end; |
1906 | while (g_ascii_isspace (*s)) | 1907 | while (g_ascii_isspace (*s)) |
1907 | s++; | 1908 | s++; |
1908 | if (*s != ')') | 1909 | if (G_UNLIKELY (*s != ')')) |
1909 | return FALSE; | 1910 | return FALSE; |
1910 | s++; | 1911 | s++; |
1911 | while (g_ascii_isspace (*s)) | 1912 | while (g_ascii_isspace (*s)) |
@@ -1998,7 +1999,7 @@ gst_structure_from_string (const gchar * string, gchar ** end) | |||
1998 | r++; | 1999 | r++; |
1999 | 2000 | ||
2000 | name = r; | 2001 | name = r; |
2001 | if (!gst_structure_parse_string (r, &w, &r)) { | 2002 | if (G_UNLIKELY (!gst_structure_parse_string (r, &w, &r))) { |
2002 | GST_WARNING ("Failed to parse structure string"); | 2003 | GST_WARNING ("Failed to parse structure string"); |
2003 | goto error; | 2004 | goto error; |
2004 | } | 2005 | } |
@@ -2024,7 +2025,7 @@ gst_structure_from_string (const gchar * string, gchar ** end) | |||
2024 | /* accept \0 as end delimiter */ | 2025 | /* accept \0 as end delimiter */ |
2025 | break; | 2026 | break; |
2026 | } | 2027 | } |
2027 | if (*r != ',') { | 2028 | if (G_UNLIKELY (*r != ',')) { |
2028 | GST_WARNING ("Failed to find delimiter, r=%s", r); | 2029 | GST_WARNING ("Failed to find delimiter, r=%s", r); |
2029 | goto error; | 2030 | goto error; |
2030 | } | 2031 | } |
@@ -2034,7 +2035,7 @@ gst_structure_from_string (const gchar * string, gchar ** end) | |||
2034 | r++; | 2035 | r++; |
2035 | 2036 | ||
2036 | memset (&field, 0, sizeof (field)); | 2037 | memset (&field, 0, sizeof (field)); |
2037 | if (!gst_structure_parse_field (r, &r, &field)) | 2038 | if (G_UNLIKELY (!gst_structure_parse_field (r, &r, &field))) |
2038 | goto error; | 2039 | goto error; |
2039 | gst_structure_set_field (structure, &field); | 2040 | gst_structure_set_field (structure, &field); |
2040 | } while (TRUE); | 2041 | } while (TRUE); |