[AD] _al_current_display

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Bit of a whinge, but can we deprecate the use of _al_current_display?
I think it's misleading.
It's used like this: (in lots of places)
ALLEGRO_BITMAP *al_get_backbuffer(void)
{
   ASSERT(_al_current_display);

   return _al_current_display->vt->get_backbuffer(_al_current_display);
}
which would be OK if _al_current_display were a global but it's actually a macro
#define _al_current_display al_get_current_display()
so that function gets called 3 separate times (all right, 2 in release
builds) .  al_get_current_display() is non-trivial because it accesses
the thread-local storage stuff, and on OS X that means a call into
pthreads.
It may not be a problem but I think it would be clearer to write
ALLEGRO_BITMAP *al_get_backbuffer(void)
{
  ALLEGRO_DISPLAY* current = al_get_current_display();
  ASSERT(current);

   return current->vt->get_backbuffer(current);
}

Pete




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/