From 75caab4ccf0a930e532fcd58e80372fe3873b3ab Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Wed, 31 May 2006 05:09:02 +0000
Subject: [PATCH] Optimize the buffer fill routine a bit.

---
 src/xpdev/xpbeep.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/xpdev/xpbeep.c b/src/xpdev/xpbeep.c
index 2f02a7bb3e..a6d960752f 100644
--- a/src/xpdev/xpbeep.c
+++ b/src/xpdev/xpbeep.c
@@ -196,12 +196,12 @@ void sdl_fillbuf(void *userdata, Uint8 *stream, int len)
 	int	copylen=len;
 	int maxlen=sdl_audio_buf_len-sdl_audio_buf_pos;
 
-	/* Fill with silence */
-	memset(stream, spec.silence, len);
-
 	/* Copy in the current buffer */
 	if(copylen>maxlen)
 		copylen=maxlen;
+	/* Fill with silence */
+	if(len>copylen)
+		memset(stream+copylen, spec.silence, len-copylen);
 	if(copylen) {
 		memcpy(stream, swave+sdl_audio_buf_pos, copylen);
 		sdl_audio_buf_pos+=copylen;
-- 
GitLab