diff options
author | Nils Wallménius <nils@rockbox.org> | 2008-11-20 20:20:43 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2008-11-20 20:20:43 +0000 |
commit | 1284c127f8e1f2ab693d523a009b7b2e553024a5 (patch) | |
tree | d3f8ed90717b8e112ce4f7196174e950eb2c2344 /apps/codecs/libtremor/codebook.c | |
parent | 7bdf9a339245058e0b394a3d3088698092c27f6f (diff) | |
download | rockbox-1284c127f8e1f2ab693d523a009b7b2e553024a5.tar.gz rockbox-1284c127f8e1f2ab693d523a009b7b2e553024a5.zip |
Introduce likely() and unlikely() macros, use to give gcc hints about which branch is likely to be taken in a conditional, use them in the midi player for a small speedup, use instead of similar EXPECT macros in tremor and use in mpegplayer
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19162 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libtremor/codebook.c')
-rw-r--r-- | apps/codecs/libtremor/codebook.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/apps/codecs/libtremor/codebook.c b/apps/codecs/libtremor/codebook.c index 8c319ab49e..5ffd0e308b 100644 --- a/apps/codecs/libtremor/codebook.c +++ b/apps/codecs/libtremor/codebook.c | |||
@@ -154,9 +154,9 @@ STIN long decode_packed_entry_number(codebook *book, | |||
154 | long lo,hi; | 154 | long lo,hi; |
155 | long lok = oggpack_look(b,book->dec_firsttablen); | 155 | long lok = oggpack_look(b,book->dec_firsttablen); |
156 | 156 | ||
157 | if (EXPECT(lok >= 0, 1)) { | 157 | if (likely(lok >= 0)) { |
158 | long entry = book->dec_firsttable[lok]; | 158 | long entry = book->dec_firsttable[lok]; |
159 | if(EXPECT(entry&0x80000000UL, 0)){ | 159 | if(unlikely(entry&0x80000000UL)){ |
160 | lo=(entry>>15)&0x7fff; | 160 | lo=(entry>>15)&0x7fff; |
161 | hi=book->used_entries-(entry&0x7fff); | 161 | hi=book->used_entries-(entry&0x7fff); |
162 | }else{ | 162 | }else{ |
@@ -218,7 +218,7 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b, | |||
218 | bitend = ((adr&3)+b->headend)*8; | 218 | bitend = ((adr&3)+b->headend)*8; |
219 | while (bufptr<bufend){ | 219 | while (bufptr<bufend){ |
220 | long entry, lo, hi; | 220 | long entry, lo, hi; |
221 | if (EXPECT(cachesize<book->dec_maxlength, 0)) { | 221 | if (unlikely(cachesize<book->dec_maxlength)) { |
222 | if (bit-cachesize+32>=bitend) | 222 | if (bit-cachesize+32>=bitend) |
223 | break; | 223 | break; |
224 | bit-=cachesize; | 224 | bit-=cachesize; |
@@ -230,13 +230,13 @@ static long decode_packed_block(codebook *book, oggpack_buffer *b, | |||
230 | } | 230 | } |
231 | 231 | ||
232 | entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)]; | 232 | entry=book->dec_firsttable[cache&((1<<book->dec_firsttablen)-1)]; |
233 | if(EXPECT(entry&0x80000000UL, 0)){ | 233 | if(unlikely(entry&0x80000000UL)){ |
234 | lo=(entry>>15)&0x7fff; | 234 | lo=(entry>>15)&0x7fff; |
235 | hi=book->used_entries-(entry&0x7fff); | 235 | hi=book->used_entries-(entry&0x7fff); |
236 | { | 236 | { |
237 | ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache); | 237 | ogg_uint32_t testword=bitreverse((ogg_uint32_t)cache); |
238 | 238 | ||
239 | while(EXPECT(hi-lo>1, 1)){ | 239 | while(likely(hi-lo>1)){ |
240 | long p=(hi-lo)>>1; | 240 | long p=(hi-lo)>>1; |
241 | if (book->codelist[lo+p]>testword) | 241 | if (book->codelist[lo+p]>testword) |
242 | hi-=p; | 242 | hi-=p; |