Sdl_ttf and SDL_Color passed by value

Is there a design reason why the SDL_Color structs are passed by value into
sdl_ttf and not passed by reference?

Well, it’s only four bytes… Probably irrelevant, but passing it by
reference would be slower even on 32 bit platforms, and even slower
with 64 bit pointers.

I think the explanation is that using a struct like this is cleaner
than using a raw 32 bit integer. (I think the resulting machine code
is identical in most cases…)

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Wednesday 24 January 2007 20:39, Luke Crook wrote:

Is there a design reason why the SDL_Color structs are passed by
value into sdl_ttf and not passed by reference?

David Olofson <david olofson.net> writes:

Is there a design reason why the SDL_Color structs are passed by
value into sdl_ttf and not passed by reference?

Well, it’s only four bytes… Probably irrelevant, but passing it by
reference would be slower even on 32 bit platforms, and even slower
with 64 bit pointers.

I think the explanation is that using a struct like this is cleaner
than using a raw 32 bit integer. (I think the resulting machine code
is identical in most cases…)

Understandable. But then SDL does not make use of the SDL_Color directly.

It just makes writing wrappers for sdl_ttf a little more work because not all
languages support passing something like a struct by value. (In my case, Common
Lisp.)

  • Luke> On Wednesday 24 January 2007 20:39, Luke Crook wrote: