gst/gstbuffer.c: Avoid costly typechecking for trivially correct pointers.

Original commit message from CVS:
* gst/gstbuffer.c: (gst_buffer_finalize):
Avoid costly typechecking for trivially correct pointers.
* gst/gstpoll.c: (gst_poll_wait):
Add some G_LIKELY here and there.
* libs/gst/base/gstadapter.c: (gst_adapter_push):
Add some debug info.
This commit is contained in:
Wim Taymans 2008-11-13 18:09:45 +00:00
parent 2488c97ebd
commit 3cc67ebab7
4 changed files with 25 additions and 6 deletions

View file

@ -1,3 +1,14 @@
2008-11-13 Wim Taymans <wim.taymans@collabora.co.uk>
* gst/gstbuffer.c: (gst_buffer_finalize):
Avoid costly typechecking for trivially correct pointers.
* gst/gstpoll.c: (gst_poll_wait):
Add some G_LIKELY here and there.
* libs/gst/base/gstadapter.c: (gst_adapter_push):
Add some debug info.
2008-11-13 Wim Taymans <wim.taymans@collabora.co.uk> 2008-11-13 Wim Taymans <wim.taymans@collabora.co.uk>
* docs/random/wtay/poll-timeout: * docs/random/wtay/poll-timeout:

View file

@ -191,7 +191,7 @@ gst_buffer_finalize (GstBuffer * buffer)
gst_caps_replace (&GST_BUFFER_CAPS (buffer), NULL); gst_caps_replace (&GST_BUFFER_CAPS (buffer), NULL);
GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (buffer)); parent_class->finalize (GST_MINI_OBJECT_CAST (buffer));
} }
/** /**

View file

@ -1038,11 +1038,11 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout)
g_mutex_lock (set->lock); g_mutex_lock (set->lock);
/* we cannot wait from multiple threads */ /* we cannot wait from multiple threads */
if (set->waiting) if (G_UNLIKELY (set->waiting))
goto already_waiting; goto already_waiting;
/* flushing, exit immediatly */ /* flushing, exit immediatly */
if (set->flushing) if (G_UNLIKELY (set->flushing))
goto flushing; goto flushing;
set->waiting = TRUE; set->waiting = TRUE;
@ -1208,18 +1208,19 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout)
g_mutex_lock (set->lock); g_mutex_lock (set->lock);
/* FIXME, can we only do this check when (res > 0)? */
gst_poll_check_ctrl_commands (set, res, &restarting); gst_poll_check_ctrl_commands (set, res, &restarting);
/* update the controllable state if needed */ /* update the controllable state if needed */
set->controllable = set->new_controllable; set->controllable = set->new_controllable;
if (set->flushing) { if (G_UNLIKELY (set->flushing)) {
/* we got woken up and we are flushing, we need to stop */ /* we got woken up and we are flushing, we need to stop */
errno = EBUSY; errno = EBUSY;
res = -1; res = -1;
break; break;
} }
} while (restarting); } while (G_UNLIKELY (restarting));
set->waiting = FALSE; set->waiting = FALSE;

View file

@ -197,16 +197,23 @@ gst_adapter_clear (GstAdapter * adapter)
void void
gst_adapter_push (GstAdapter * adapter, GstBuffer * buf) gst_adapter_push (GstAdapter * adapter, GstBuffer * buf)
{ {
guint size;
g_return_if_fail (GST_IS_ADAPTER (adapter)); g_return_if_fail (GST_IS_ADAPTER (adapter));
g_return_if_fail (GST_IS_BUFFER (buf)); g_return_if_fail (GST_IS_BUFFER (buf));
adapter->size += GST_BUFFER_SIZE (buf); size = GST_BUFFER_SIZE (buf);
adapter->size += size;
/* Note: merging buffers at this point is premature. */ /* Note: merging buffers at this point is premature. */
if (G_UNLIKELY (adapter->buflist == NULL)) { if (G_UNLIKELY (adapter->buflist == NULL)) {
GST_LOG_OBJECT (adapter, "pushing first %u bytes", size);
adapter->buflist = adapter->buflist_end = g_slist_append (NULL, buf); adapter->buflist = adapter->buflist_end = g_slist_append (NULL, buf);
} else { } else {
/* Otherwise append to the end, and advance our end pointer */ /* Otherwise append to the end, and advance our end pointer */
GST_LOG_OBJECT (adapter, "pushing %u bytes at end, size now %u", size,
adapter->size);
adapter->buflist_end = g_slist_append (adapter->buflist_end, buf); adapter->buflist_end = g_slist_append (adapter->buflist_end, buf);
adapter->buflist_end = g_slist_next (adapter->buflist_end); adapter->buflist_end = g_slist_next (adapter->buflist_end);
} }