micro-optim: if (x) is cheaper than if (x > 0) for unsigned integers

This commit is contained in:
Edward Hervey 2009-04-11 15:04:41 +02:00
parent 5519b1fcb1
commit 6aa8ca37ee
13 changed files with 37 additions and 37 deletions

View file

@ -572,7 +572,7 @@ gst_buffer_create_sub (GstBuffer * buffer, guint offset, guint size)
gboolean complete;
g_return_val_if_fail (buffer != NULL, NULL);
g_return_val_if_fail (buffer->mini_object.refcount > 0, NULL);
g_return_val_if_fail (buffer->mini_object.refcount, NULL);
g_return_val_if_fail (buffer->size >= offset + size, NULL);
/* find real parent */
@ -652,8 +652,8 @@ gboolean
gst_buffer_is_span_fast (GstBuffer * buf1, GstBuffer * buf2)
{
g_return_val_if_fail (buf1 != NULL && buf2 != NULL, FALSE);
g_return_val_if_fail (buf1->mini_object.refcount > 0, FALSE);
g_return_val_if_fail (buf2->mini_object.refcount > 0, FALSE);
g_return_val_if_fail (buf1->mini_object.refcount, FALSE);
g_return_val_if_fail (buf2->mini_object.refcount, FALSE);
/* it's only fast if we have subbuffers of the same parent */
return (GST_IS_SUBBUFFER (buf1) &&
@ -690,9 +690,9 @@ gst_buffer_span (GstBuffer * buf1, guint32 offset, GstBuffer * buf2,
GstBuffer *newbuf;
g_return_val_if_fail (buf1 != NULL && buf2 != NULL, NULL);
g_return_val_if_fail (buf1->mini_object.refcount > 0, NULL);
g_return_val_if_fail (buf2->mini_object.refcount > 0, NULL);
g_return_val_if_fail (len > 0, NULL);
g_return_val_if_fail (buf1->mini_object.refcount, NULL);
g_return_val_if_fail (buf2->mini_object.refcount, NULL);
g_return_val_if_fail (len, NULL);
g_return_val_if_fail (len <= buf1->size + buf2->size - offset, NULL);
/* if the two buffers have the same parent and are adjacent */

View file

@ -313,7 +313,7 @@ gst_bus_post (GstBus * bus, GstMessage * message)
handler = bus->sync_handler;
handler_data = bus->sync_handler_data;
emit_sync_message = bus->priv->num_sync_message_emitters > 0;
emit_sync_message = bus->priv->num_sync_message_emitters;
GST_OBJECT_UNLOCK (bus);
/* first call the sync handler if it is installed */
@ -1215,7 +1215,7 @@ gst_bus_add_signal_watch_full (GstBus * bus, gint priority)
/* I know the callees don't take this lock, so go ahead and abuse it */
GST_OBJECT_LOCK (bus);
if (bus->num_signal_watchers > 0)
if (bus->num_signal_watchers)
goto done;
/* this should not fail because the counter above takes care of it */
@ -1288,7 +1288,7 @@ gst_bus_remove_signal_watch (GstBus * bus)
bus->num_signal_watchers--;
if (bus->num_signal_watchers > 0)
if (bus->num_signal_watchers)
goto done;
id = bus->signal_watch_id;

View file

@ -405,7 +405,7 @@ gst_caps_ref (GstCaps * caps)
GST_CAT_TRACE (GST_CAT_REFCOUNTING, "%p %d->%d", caps,
GST_CAPS_REFCOUNT_VALUE (caps), GST_CAPS_REFCOUNT_VALUE (caps) + 1);
#endif
g_return_val_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0, NULL);
g_return_val_if_fail (GST_CAPS_REFCOUNT_VALUE (caps), NULL);
g_atomic_int_inc (&caps->refcount);
@ -429,7 +429,7 @@ gst_caps_unref (GstCaps * caps)
GST_CAPS_REFCOUNT_VALUE (caps), GST_CAPS_REFCOUNT_VALUE (caps) - 1);
#endif
g_return_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0);
g_return_if_fail (GST_CAPS_REFCOUNT_VALUE (caps));
/* if we ended up with the refcount at zero, free the caps */
if (G_UNLIKELY (g_atomic_int_dec_and_test (&caps->refcount)))
@ -474,7 +474,7 @@ gst_static_caps_get (GstStaticCaps * static_caps)
G_LOCK (static_caps_lock);
/* check if other thread already updated */
if (G_UNLIKELY (g_atomic_int_get (&caps->refcount) > 0))
if (G_UNLIKELY (g_atomic_int_get (&caps->refcount)))
goto done;
string = static_caps->string;
@ -1591,7 +1591,7 @@ gst_caps_subtract (const GstCaps * minuend, const GstCaps * subtrahend)
Note: there's a test that checks this behaviour. */
g_return_val_if_fail (!CAPS_IS_ANY (minuend), NULL);
sublen = subtrahend->structs->len;
g_assert (sublen > 0);
g_assert (sublen);
src = gst_caps_copy (minuend);
for (i = 0; i < sublen; i++) {
@ -2087,7 +2087,7 @@ gst_caps_to_string (const GstCaps * caps)
for (i = 0; i < clen; i++) {
GstStructure *structure;
if (i > 0) {
if (i) {
/* ';' is now added by gst_structure_to_string */
g_string_append_c (s, ' ');
}

View file

@ -1004,7 +1004,7 @@ gst_clock_set_calibration (GstClock * clock, GstClockTime internal, GstClockTime
{
g_return_if_fail (GST_IS_CLOCK (clock));
g_return_if_fail (rate_num != GST_CLOCK_TIME_NONE);
g_return_if_fail (rate_denom > 0 && rate_denom != GST_CLOCK_TIME_NONE);
g_return_if_fail (rate_denom && rate_denom != GST_CLOCK_TIME_NONE);
write_seqlock (clock);
GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock,

View file

@ -357,7 +357,7 @@ void
gst_mini_object_unref (GstMiniObject * mini_object)
{
g_return_if_fail (GST_IS_MINI_OBJECT (mini_object));
g_return_if_fail (mini_object->refcount > 0);
g_return_if_fail (mini_object->refcount);
GST_CAT_TRACE (GST_CAT_REFCOUNTING, "%p unref %d->%d",
mini_object,

View file

@ -329,7 +329,7 @@ void
gst_object_unref (gpointer object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (((GObject *) object)->ref_count > 0);
g_return_if_fail (((GObject *) object)->ref_count);
#ifdef DEBUG_REFCOUNT
GST_CAT_TRACE_OBJECT (GST_CAT_REFCOUNTING, object, "%p unref %d->%d", object,

View file

@ -4174,7 +4174,7 @@ gst_pad_chain_data_unchecked (GstPad * pad, gboolean is_buffer, void *data,
caps = gst_pad_data_get_caps (is_buffer, data);
caps_changed = caps && caps != GST_PAD_CAPS (pad);
emit_signal = GST_PAD_DO_BUFFER_SIGNALS (pad) > 0;
emit_signal = GST_PAD_DO_BUFFER_SIGNALS (pad) != 0;
GST_OBJECT_UNLOCK (pad);
/* see if the signal should be emited, we emit before caps nego as
@ -4409,7 +4409,7 @@ gst_pad_push_data (GstPad * pad, gboolean is_buffer, void *data,
/* we emit signals on the pad arg, the peer will have a chance to
* emit in the _chain() function */
if (G_UNLIKELY (GST_PAD_DO_BUFFER_SIGNALS (pad) > 0)) {
if (G_UNLIKELY (GST_PAD_DO_BUFFER_SIGNALS (pad))) {
cache = NULL;
/* unlock before emitting */
GST_OBJECT_UNLOCK (pad);
@ -4866,7 +4866,7 @@ gst_pad_get_range_unchecked (GstPad * pad, guint64 offset, guint size,
if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
goto flushing;
emit_signal = GST_PAD_DO_BUFFER_SIGNALS (pad) > 0;
emit_signal = GST_PAD_DO_BUFFER_SIGNALS (pad) != 0;
GST_OBJECT_UNLOCK (pad);
if (G_UNLIKELY ((getrangefunc = GST_PAD_GETRANGEFUNC (pad)) == NULL))
@ -5034,7 +5034,7 @@ gst_pad_pull_range (GstPad * pad, guint64 offset, guint size,
/* signal emision for the pad, peer has chance to emit when
* we call _get_range() */
emit_signal = GST_PAD_DO_BUFFER_SIGNALS (pad) > 0;
emit_signal = GST_PAD_DO_BUFFER_SIGNALS (pad) != 0;
gst_object_ref (peer);
GST_OBJECT_UNLOCK (pad);
@ -5172,7 +5172,7 @@ gst_pad_push_event (GstPad * pad, GstEvent * event)
GST_EVENT_SRC (event) = gst_object_ref (pad);
}
if (G_UNLIKELY (GST_PAD_DO_EVENT_SIGNALS (pad) > 0)) {
if (G_UNLIKELY (GST_PAD_DO_EVENT_SIGNALS (pad) != 0)) {
GST_OBJECT_UNLOCK (pad);
if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT (event)))
@ -5279,7 +5279,7 @@ gst_pad_send_event (GstPad * pad, GstEvent * event)
}
/* pad signals */
if (G_UNLIKELY (GST_PAD_DO_EVENT_SIGNALS (pad) > 0)) {
if (G_UNLIKELY (GST_PAD_DO_EVENT_SIGNALS (pad) != 0)) {
GST_OBJECT_UNLOCK (pad);
if (!gst_pad_emit_have_data_signal (pad, GST_MINI_OBJECT_CAST (event)))

View file

@ -1126,7 +1126,7 @@ gst_registry_scan_path_level (GstRegistryScanContext * context,
/* FIXME 0.11: Don't recurse into directories, this behaviour
* is inconsistent with other PATH environment variables
*/
if (level > 0) {
if (level) {
GST_LOG_OBJECT (context->registry, "recursing into directory %s",
filename);
changed |= gst_registry_scan_path_level (context, filename, level - 1);

View file

@ -1744,7 +1744,7 @@ gst_structure_value_get_generic_type (GValue * val)
|| G_VALUE_TYPE (val) == GST_TYPE_ARRAY) {
GArray *array = g_value_peek_pointer (val);
if (array->len > 0) {
if (array->len) {
GValue *value = &g_array_index (array, GValue, 0);
return gst_structure_value_get_generic_type (value);

View file

@ -334,7 +334,7 @@ gst_system_clock_add_wakeup (GstSystemClock * sysclock)
static void
gst_system_clock_wait_wakeup (GstSystemClock * sysclock)
{
while (sysclock->priv->wakeup_count > 0) {
while (sysclock->priv->wakeup_count) {
GST_CLOCK_WAIT (sysclock);
}
}

View file

@ -1162,7 +1162,7 @@ gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag,
return NULL;
return gst_value_list_get_value (value, index);
} else {
if (index > 0)
if (index)
return NULL;
return value;
}

View file

@ -307,7 +307,7 @@ gst_util_div128_64 (GstUInt64 c1, GstUInt64 c0, guint64 denom)
* part of denom since denom > G_MAXUINT32. */
s = gst_util_clz (v.l.high);
if (s > 0) {
if (s) {
/* normalize divisor and dividend */
v.ll <<= s;
c1.ll = (c1.ll << s) | (c0.l.high >> (32 - s));
@ -3367,7 +3367,7 @@ void
gst_pad_remove_data_probe (GstPad * pad, guint handler_id)
{
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (handler_id > 0);
g_return_if_fail (handler_id);
GST_OBJECT_LOCK (pad);
g_signal_handler_disconnect (pad, handler_id);
@ -3391,7 +3391,7 @@ void
gst_pad_remove_event_probe (GstPad * pad, guint handler_id)
{
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (handler_id > 0);
g_return_if_fail (handler_id);
GST_OBJECT_LOCK (pad);
g_signal_handler_disconnect (pad, handler_id);
@ -3413,7 +3413,7 @@ void
gst_pad_remove_buffer_probe (GstPad * pad, guint handler_id)
{
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (handler_id > 0);
g_return_if_fail (handler_id);
GST_OBJECT_LOCK (pad);
g_signal_handler_disconnect (pad, handler_id);

View file

@ -891,7 +891,7 @@ gst_queue_is_empty (GstQueue * queue)
* Therefore, only consider it empty if it is not filled. */
return ((queue->min_threshold.buffers > 0 &&
queue->cur_level.buffers < queue->min_threshold.buffers) ||
(queue->min_threshold.bytes > 0 &&
(queue->min_threshold.bytes &&
queue->cur_level.bytes < queue->min_threshold.bytes) ||
(queue->min_threshold.time > 0 &&
queue->cur_level.time < queue->min_threshold.time)) &&
@ -901,11 +901,11 @@ gst_queue_is_empty (GstQueue * queue)
static gboolean
gst_queue_is_filled (GstQueue * queue)
{
return (((queue->max_size.buffers > 0 &&
return (((queue->max_size.buffers &&
queue->cur_level.buffers >= queue->max_size.buffers) ||
(queue->max_size.bytes > 0 &&
(queue->max_size.bytes &&
queue->cur_level.bytes >= queue->max_size.bytes) ||
(queue->max_size.time > 0 &&
(queue->max_size.time &&
queue->cur_level.time >= queue->max_size.time)));
}
@ -1344,13 +1344,13 @@ gst_queue_handle_src_query (GstPad * pad, GstQuery * query)
* limit, the best thing we can do is to return an infinite delay. In
* reality a better estimate would be the byte/buffer rate but that is not
* possible right now. */
if (queue->max_size.time > 0 && max != -1)
if (queue->max_size.time && max != -1)
max += queue->max_size.time;
else
max = -1;
/* adjust for min-threshold */
if (queue->min_threshold.time > 0 && min != -1)
if (queue->min_threshold.time && min != -1)
min += queue->min_threshold.time;
gst_query_set_latency (query, live, min, max);