GNOME Bugzilla – Bug 594225
[API] [bytereader] add _unchecked() variants and inline most common functions
Last modified: 2009-09-06 18:45:31 UTC
I propose (inlined) _unchecked() variants for the most common get and peek functions. This is useful e.g. for reading data in inner loops where we've already checked that sufficient data is available. Of course GST_READ_*() could be used there, but I believe that using GstByteReader + _unchecked() functions is generally the better alternative because the code isn't cluttered with statements that move the read pointer forward, and also the _unchecked() suffix makes it clear that one should check whether there's enough data available beforehand. Secondly, I propose to inline the most common getters and setters. The attached patch does this by adding private _gst_byter_reader_*inline() variants and then mapping the normal functions to the inline functions with an additional G_LIKELY where it makes sense. Besides the presumed performance increase through inlining, I hope the compiler will be able to generate better/tighter code for the most common use case where the byte reader is allocated on the stack and not touched by any external functions. The change also cleans up the code a bit by removing the non-macro generated special cases for *int8, *int24 and float* (hopefully correctly).
Created attachment 142528 [details] [review] bytereader: add inlined _unchecked() variants for some functions
Created attachment 142529 [details] [review] bytereader: add inline versions of the most common getters and setter
Created attachment 142530 [details] [review] bytereader: add unchecked and inline versions of the float getters/peekers
Looks good, please commit :) But please add a FIXME 0.11 so we can remove the functions for 0.11 (and the same for the bitreader too I guess).
commit 96a565bdca71ca8d9ac27b75e25a767cd8e6ad45 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Sun Sep 6 19:43:47 2009 +0100 bitreader, bytereader: add some FIXME 0.11 comments and fix indenting commit 4c103b00b5f3accad40759170138076e278c36b2 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Fri Sep 4 17:15:35 2009 +0100 bytereader: add unchecked and inline versions of the float getters/peekers API: gst_byte_reader_get_float*_unchecked() commit 31ab1244871e1ef5cce3c571ffb3c20805b3ba8b Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Fri Sep 4 16:52:06 2009 +0100 bytereader: add inline versions of the most common getters and setters commit 080b2e4fd547f371b727a5d20e05beecef748ece Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Wed Sep 2 11:20:04 2009 +0100 bytereader: add inlined _unchecked() variants for some functions API: gst_byte_reader_skip_unchecked() API: gst_byte_reader_peek_*_unchecked() API: gst_byte_reader_get_*_unchecked() API: gst_byte_reader_{peek,get,dup}_data_unchecked()