Skip to content

Introduce static get and set functions for ControlObject#28

Merged
daschuer merged 1 commit into
mixxxdj:masterfrom
daschuer:atomic-co
Jun 28, 2013
Merged

Introduce static get and set functions for ControlObject#28
daschuer merged 1 commit into
mixxxdj:masterfrom
daschuer:atomic-co

Conversation

@daschuer
Copy link
Copy Markdown
Member

This is a next step to get rid of the double hash in CO and COP

@rryan
Copy link
Copy Markdown
Member

rryan commented Jun 28, 2013

LGTM -- it may be useful to provide a default value or a bool* that is set if the control existed or not but whoever needs that first can add it.

@daschuer
Copy link
Copy Markdown
Member Author

Thank you for review!

daschuer added a commit that referenced this pull request Jun 28, 2013
Introduce static get and set functions for ControlObject
@daschuer daschuer merged commit 82c4a75 into mixxxdj:master Jun 28, 2013
Comment thread src/controlobject.h
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I know this has already been merged -- but what reasoning exists for taking a constant ref to a double instead of just passing a double?

For all the stylistic nits I see being picked on in github mail, this seems exceptionally odd to go uncommented.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any style issues. The & is in the right place :P.

Doubles are 64-bit so on a 32-bit platform passing by reference is slightly less data to push on the stack.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be my favourite comment ever, Bill. 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not worth talking about, but since I am an embedded developer I wanted to know. So I have written a test with an interesting results:

  1. When passing a double or a double& to a function with compatible parameters there is no difference because the parameters are not touched.
  2. When passing a double to a function with incompatible parameters it requires two more instructions then a double& on a 32bit target. On a 64 bit target it is the same.
  3. Making a double from a double& takes at least on instruction more for fetching the address of the defence on both architectures.
  4. passing a double& in one call and the passing a double in a sub call takes 3 instructions more than passing double in both calls, on a both targets. On a 64 bit system both versions are two instructions shorter.

Conclusion:
There is no general answer what is best, but we should avoid converting between double and double&.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants