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

Holger Freyther holger at freyther.de
Wed Mar 23 10:34:13 UTC 2016


> On 23 Mar 2016, at 11:23, Jacob <jacob01 at gmx.net> wrote:
> 
> Hi

Hi,


>> 
>> 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.

Given your other argument about the reference I will not merge the patch but could you explain why

	isCompatible(), isFamilyCompatible(), ... and
	pdch::rcv_data_block, rcv_block_gprs

require a mutable argument? I assume that ::inc/::dec should never be called on objects routines? From this point of view I think it is favorable to mark these methods with const parameters? What is your take here?



>>> 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).


good point. I think either way the performance for this one will not be noticeable.

holger


More information about the osmocom-net-gprs mailing list