[FFmpeg-cvslog] r11573 - trunk/libavformat/mxf.c

Rich Felker dalias
Sun Jan 20 01:10:54 CET 2008


On Sat, Jan 19, 2008 at 09:50:18PM +0000, M?ns Rullg?rd wrote:
> >> >> -        UID uid;
> >> >> +        UID uid = {0};
> >> >
> >> > I'm quite sure it does not matter here, but note that even for arrays as
> >> > small as 16 bytes memset is quite a bit faster than this kind of
> >> > initialization, at least with gcc around 3.4
> >> 
> >> If memset is the fastest way, gcc should know to call it in such
> >> situations.  I've seen gcc generate memcpy() calls for struct
> >> assignments, so it's certainly something that is reasonable to expect.
> >
> > Certainly gcc should know, back then it didn't though (I noticed it
> > while optimizing libfaad back then).
> 
> If recent gcc versions get it right, I see no reason to obfuscate the code.

For structs, memset and memcpy are much better than assignment or
initialization, which are not guaranteed to zero out any padding. This
is not an issue of implementation but of what the C language itself
guarantees.

Rich




More information about the ffmpeg-cvslog mailing list