[FFmpeg-devel] [PATCH] Make img_tags fall into .rodata

Diego 'Flameeyes' Pettenò flameeyes
Fri May 2 19:48:35 CEST 2008

Michael Niedermayer <michaelni at gmx.at> writes:

> Why would we want it to be a power of 2?

Access to the N-th element of an array for the compiler is

*(&array + N*sizeof(array[0]))

when N is a power of 2, it would just be a shift to the right, rather
than a multiplication. On every architecture I know a bit of, shift to
right is faster than multiplication.

Of course if the compiler is good enough it would know it's iterating
sequentially and just use a temporary pointer and sum sizeof(array[0])
in it, but it's not bad to help out not-so-smart compilers, I didn't do
the math actually, but I'd say _if_ it wastes space on 32-bit
architectures, it's a very limited waste, which might actually help.

Diego "Flameeyes" Petten?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080502/3926826c/attachment.pgp>

More information about the ffmpeg-devel mailing list