GNOME Bugzilla – Bug 590941
API: add gst_pad_get_caps() variant that avoids unneeded caps copies
Last modified: 2009-11-05 22:53:49 UTC
gst_pad_get_caps (and therefore also gst_pad_peer_get_caps) promisses to return writable caps. To ensure that it copies caps in most cases. This has two bad side-effects: * copying is often not needed (e.g. when using the caps to calculating an intersection) * when caps are copied we cannot compare pointers to benefit from quickly leaving some operations The attached patch adds variants that don't copy and makes use of them in core. I am not entierly happy with the naming. Any ideas?
Created attachment 140016 [details] [review] adds and uses non-copying gst_caps function
as of irc discussion - _get_caps_nocopy() seem to be the favorite. I'll redo the patch.
Well _get_caps_nocopy() is not good, as gst_pad_get_caps(9 not neccesarily copies.
Created attachment 144935 [details] [review] adds and uses non-copying gst_caps function update for latest git-head
commit fcc5d783df0a8461250da1e0434132d580ec8adf Author: Stefan Kost <ensonic@users.sf.net> Date: Wed Oct 7 11:43:54 2009 +0300 pad: add variants of gst_pad_get_caps() that don't copy caps. Fixes #590941 In most places in core and baseclasses we just need the caps to do caps- intersections. In that case ref'ed caps are enough (no need to copy). This patch also switches the code to use the new functions. API: gst_pad_get_caps_refed(), gst_pad_peer_get_caps_refed()
Hrm, I quite dislike _refed(). It just looks wrong to me. At the very least we should rename it to _reffed() IMHO. Re-opening to collect some more opinions (sorry).
Why reffed with a doubled 'ff'. It comes from 'referenced' as in http://www.merriam-webster.com/dictionary/referenced Also what looks wrong to you - the naming or the functionality? We discussed the nameing before. _nocopy would suggest that gst_pad_get_caps always copies (which it does not). Ideally we would rename gst_pad_get_caps() to gst_pad_get_writable_caps() if we want to have such a utility function at all. gst_pad_get_caps_refed() is what the actual gst_pad_get_caps() should have been.
Also as a very non scientific approch to the spelling: http://www.googlefight.com/index.php?lang=en_GB&word1=reffed&word2=refed
> Also as a very non scientific approch to the spelling: > http://www.googlefight.com/index.php?lang=en_GB&word1=reffed&word2=refed Yes, that's because it's used a lot in connection with words like 'birds', 'rats' and 'feeding' ;-)
What about gst_pad_get_caps_nocopy() ?
(In reply to comment #10) > What about gst_pad_get_caps_nocopy() ? See comment #3 and comment #7.
Just for the record, its now _reffed.