可能是android renderscript源中的一个小错误

0 android renderscript

只是查看renderscript源代码.我想我在第36行发现了一个错误

private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV;
Run Code Online (Sandbox Code Playgroud)

认为需要是双倍的==但没有足够的编码经验才能确定.

pax*_*blo 7

不,我不认为这一个错误.它设置LOG_ENABLEDLOGDLOGV取决于的值DEBUG.

相关的一点是:

public class RenderScript {
    static final String LOG_TAG = "libRS_jni";
    private static final boolean DEBUG  = false;
    @SuppressWarnings({"UnusedDeclaration", "deprecation"})
    private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV;
Run Code Online (Sandbox Code Playgroud)

最后一行在概念上等同于:

    private static final boolean LOG_ENABLED;
    if (DEBUG)
        LOG_ENABLED = Config.LOGD;
    else
        LOG_ENABLED = Config.LOGV;
Run Code Online (Sandbox Code Playgroud)

事实上,

private static final boolean LOG_ENABLED == DEBUG ? Config.LOGD : Config.LOGV;
Run Code Online (Sandbox Code Playgroud)

实际上没有意义,因为它意味着:

private static final boolean ((LOG_ENABLED == DEBUG)
                               ? Config.LOGD
                               : Config.LOGV);
Run Code Online (Sandbox Code Playgroud)

它根本没有声明变量名,只是一个应分配给某个东西的值.