[FFmpeg-devel] [patch 1/3]Fix bug for POWER LE: /libavcodec/ppc/me_cmp.c

Timothy Gu timothygu99 at gmail.com
Sun Nov 2 05:37:20 CET 2014


你好:
Hi,

On Friday, October 31, 2014, Michael Niedermayer <michaelni at gmx.at> wrote:

>
> Why do you keep sending patches which duplicate code?
>
> Maybe someone can translate this to a language you understand
> better then english:


This is an Chinese translation. Hope this helps.
我把Michael的邮件翻译了一下。


>
> Code duplication is not allowed


请不要重复使用同一个代码。如果有几种不同的版本的代码,请不要做这个:


>
> #if A
>  foo
>  this
>  bar
> #else
>  foo
>  that
>  bar
> #endif


这样,foo和bar被重复使用了。如果我们以后在更改第一条"foo"时很容易会把第二条foo忘了。请使用这样的格式:


>
>  foo
> #if A
>  this
> #else
>  that
> #endif
>  bar
>

 这样,不仅让代码跟容易阅读,以后出错的可能性会更小。

>
> also the then remaining difference (this vs that) should be avoided
> as well by using appropriate macros and inline functions


如果可能的话,您还可以把不同的部分用一个宏来简化。比如说:

(放在文件头里)
#ifdef HAVE_BIGENDIAN
#define DIFFERENT_PART this
#else
#define DIFFERENT_PART that
#endif

(放在源代码里)
foo
DIFFERENT_PART
bar


> there is already some duplicated code in there, this was a mistake.


现在FFmpeg已经有一些重复的代码。这是一个我们以前犯的错误。


> No more duplicated code should be added.


请不要再添加新的重复的代码。

如果你还有问题,我们一定会尽我们全力解释。

Timothy


More information about the ffmpeg-devel mailing list