thedmd / pixeltoaster

PixelToaster is a framebuffer library for C++
45 stars 9 forks source link

Mouse should be passed by const reference #61

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The onMouseXXX events on the Listener currently receive the Mouse data by
value.  Since this is two floats and three bools, this can be up to 5 * 4
bytes on a 32 bit machine.  Though it has a trivial copy constructor, it is
still 20 bytes to be copied.  It might be interesting to pass by constant
reference instead.

BACKWARDS INCOMPATIBILITY: Doing so will break existing code though! 
Without any compiler error or warning!  We might get around this by
supplying forwarding to the existing signature by default, but maybe it's
better to just break it straight away.

Waiting for your opinion,
Bram

Original issue reported on code.google.com by bram.deg...@gmail.com on 26 Jul 2007 at 1:22

GoogleCodeExporter commented 8 years ago
Once we pass by const reference, it may also be possible to send other mouse 
data in
the future at no extra cost.  For example, sending delta updates like requested 
here:
http://pixeltoaster.com/forum/index.php?PHPSESSID=a51670964328883a092a58556b0af9
be&topic=98.0

Original comment by bram.deg...@gmail.com on 26 Jul 2007 at 1:26

GoogleCodeExporter commented 8 years ago
i think we should leave it as it is for now, there is also a reason i think i 
went
with pass by value as well btw. i forget what it is though - i wouldnt do such a
thing without having some reason, i tend to obsess over the API

i'll see if i can remember, i'm a bit distracted by a girl at the moment!

Original comment by glenn.fi...@gmail.com on 26 Jul 2007 at 10:55

GoogleCodeExporter commented 8 years ago
I understand ;)

But it would be nice to know why exactly you've made that choice.

Original comment by bram.deg...@gmail.com on 30 Jul 2007 at 1:45

GoogleCodeExporter commented 8 years ago
i'll look at it this weekend coming up and see if i can remember, it could have
simply been laziness ;)

Original comment by glenn.fi...@gmail.com on 30 Jul 2007 at 5:00

GoogleCodeExporter commented 8 years ago
leaving it as is, the choice was made because the mouse struct isnt very big, 
so its not too bad to pass it into the 
stack

Original comment by glenn.fi...@gmail.com on 13 Sep 2008 at 4:01