diff options
author | Max Kellermann <max@duempel.org> | 2008-04-12 04:19:59 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-04-12 04:19:59 +0000 |
commit | 51e9044098bf44a5d4578ce405468454be7a4c8e (patch) | |
tree | a421cbd9b04a4efd33ebd217cafaa94d7e0a316e /src/inputPlugins | |
parent | 96eb0119cce704c10f43aae422cd56594af0a29c (diff) | |
download | mpd-51e9044098bf44a5d4578ce405468454be7a4c8e.tar.gz mpd-51e9044098bf44a5d4578ce405468454be7a4c8e.tar.xz mpd-51e9044098bf44a5d4578ce405468454be7a4c8e.zip |
don't calculate bytes per sample within the loop
AudioFormat.bits is volatile, and to read it, 3 pointers had to be
deferenced. Calculate this value once. This speeds up this function
by 5%.
git-svn-id: https://svn.musicpd.org/mpd/trunk@7325 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/inputPlugins')
-rw-r--r-- | src/inputPlugins/flac_plugin.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index fc55919b4..fa6304980 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -216,6 +216,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, FLAC__uint16 u16; unsigned char *uc; unsigned int c_samp, c_chan; + const unsigned int bytes_per_sample = (data->dc->audioFormat.bits / 8); unsigned int i; float timeChange; FLAC__uint64 newPosition = 0; @@ -241,7 +242,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, c_chan++) { u16 = buf[c_chan][c_samp]; uc = (unsigned char *)&u16; - for (i = 0; i < (unsigned)(data->dc->audioFormat.bits / 8); i++) { + for (i = 0; i < bytes_per_sample; i++) { if (data->chunk_length >= FLAC_CHUNK_SIZE) { if (flacSendChunk(data) < 0) { return |