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


当前回答

// StupidCompilerDontInline(SCDI), in the test project where
// allcode was in a single cpp the compiler had inlined nearly
// everything which lead to nice stackoverflow.
// To prevent this the metods are made virtual
#define SCDI virtual

其他回答

// TODO: Finish.

从《雷神之锤III》的资料中,我在一些随机的帖子中偶然发现了这一点。该文件的完整源代码可以在这里找到。这是一种非常快速的求平方根倒数的方法。至于最好的评论呢?当然,这是一种常见的方法,但考虑到它附着在直线上,它的神奇之处在于它的伟大之处。

float Q_rsqrt( float number )
{
  long i;
  float x2, y;
  const float threehalfs = 1.5F;

  x2 = number * 0.5F;
  y  = number;
  i  = * ( long * ) &y;  // evil floating point bit level hacking
  i  = 0x5f3759df - ( i >> 1 ); // what the fuck?
  y  = * ( float * ) &i;
  y  = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
  // y  = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

  #ifndef Q3_VM
  #ifdef __linux__
    assert( !isnan(y) ); // bk010122 - FPE?
  #endif
  #endif
  return y;
}

不是真的评论:

DvLog::Log("This silly log message fixes a PSCRIPT5.DLL gpf when printing to Adobe.");

可悲的是,没有评论,PSCRIPT5.DLL真的炸了…

 // WARNING!!!
 // Very perversive code ahead!

... about a 20 lines of "very perversive" code ...

// Now you can call your grandmother back. ;)
Fix problem where Nulls don't work properly.  Stupid Microsoft!

代码以迂回的方式一行一行地将null转换为零长度的字符串,因为愚蠢的程序员不理解null是什么,也从未听说过Nz()函数。