你遇到过的源代码中最好的注释是什么?


当前回答

在eMule, Preferences.cpp中,强制最小上传速度限制与下载速度限制成正比的方法:

uint16 CPreferences::GetMaxDownload(){
//dont be a Lam3r :)
    uint16 maxup=(GetMaxUpload()==UNLIMITED)?GetMaxGraphUploadRate():GetMaxUpload();
    if( maxup < 4 )
        return (( (maxup < 10) && (maxup*3 < prefs->maxdownload) )? maxup*3 : prefs->maxdownload);
    return (( (maxup < 10) && (maxup*4 < prefs->maxdownload) )? maxup*4 : prefs->maxdownload);
}

其他回答

public int hashCode() {
//sucks, but what're you gonna do

/*
int hash = 7;
for (int i = 0; i < array.length; i++)
    hash = hash * 31 * (null == array[i] ? 0 : array[i].hashCode());
return hash;
*/

return 0;
}
int main(void)
/* Program starts here */
// BEGIN HACK
...
// END HACK: I feel dirty.
// this error could never happen

然后,客户打电话说他看到一条错误消息说"这个错误永远不会发生"

#define SHIT_HAPPENED (BASE + 1)   /* generic shit happened */