[PATCH 2/2] Avoid copy constructor in uplink tbf path

Jacob jacob01 at gmx.net
Wed Mar 23 10:23:04 UTC 2016


Hi

On 22.03.2016 21:26, Holger Freyther wrote:
> 
>> On 22 Mar 2016, at 14:12, Bhargava Abhyankar <Bhargava.Abhyankar at radisys.com> wrote:
>>
>> The copy constructor of GprsCodingScheme class object used in
>> uplink tbf path is replaced by the reference variable.
>> Appropriate function prototypes and function definition are
>> changed.
> 
> yes, it is good style to mark them as const (and pass them as reference).

Hmm. I do not agree. Passing as reference doesn't make much sense here
(there is not performance issue and no risk of slicing). It just an
integer/enum disguised as class and it is meant be used like an enum.
But of course, if it was a reference, marking it as const would be good.

> 
> 
>> This patch will increase efficiency of the code.

No, using a reference in general (unless inlining is done) will
eventually result in a larger variable/parameter/field size (depending
on the enum size and the pointer size on the target plattform, where the
pointer size will be >= enum size on all platforms I know of). In
addition, dereferencing is needed which cost additional instructions and
memory accesses (albeit with a high probability for a cache hit, if
there is any).

So in my personal opinion I wouldn't merge this patch, BYMMV.

Kind regards

Jacob

> 
> Given the size of the member and that the constructor is inlined my first assumption is that for this specific type the runtime cost of copying m_scheme and a pointer will be about the same.
> 


More information about the osmocom-net-gprs mailing list