Skip to content

Commit

Permalink
Minor optimization; early exit when enough buffers found.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jun 28, 2004
1 parent 9350e36 commit f94bc79
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions osx/alBuffer.c
Expand Up @@ -111,12 +111,16 @@ ALAPI ALvoid ALAPIENTRY alGenBuffers(ALsizei n, ALuint *buffers)
// check if there're enough buffers available...
for (i = 0, buf = ctx->buffers; i < AL_MAXBUFFERS; i++, buf++)
{
if (!buf->inUse)
iCount++;
if (!buf->inUse)
{
iCount++;
if (iCount >= n)
break;
} // if
} // for

if (iCount < n)
__alSetError(AL_INVALID_VALUE);
__alSetError(AL_OUT_OF_MEMORY); // !!! FIXME: Better error?
else
{
iCount = 0;
Expand Down

0 comments on commit f94bc79

Please sign in to comment.