From fb95c6593f89780167a7b07f05e4bb1784907603 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 1 Jul 2022 00:39:28 -0400
Subject: [PATCH] Mix_GroupCount: Don't bother going through the loop if
tag==-1.
Just a minor optimization.
---
src/mixer.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/mixer.c b/src/mixer.c
index 3d3dfa3a..b6694610 100644
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -1457,8 +1457,13 @@ int Mix_GroupCount(int tag)
{
int count = 0;
int i;
+
+ if (tag == -1) {
+ return num_channels; /* minor optimization; no need to go through the loop. */
+ }
+
for(i=0; i < num_channels; i ++) {
- if (mix_channel[i].tag==tag || tag==-1)
+ if (mix_channel[i].tag == tag)
++ count;
}
return(count);