I don't get this C/C++ Joke

后端 未结 6 1090
北海茫月
北海茫月 2021-01-31 15:57

After reading this article on thedailywtf.com, I\'m not sure that I really got the joke.

It says there that some guy changed the code from

int function()         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-31 16:50

    Yes, the second code is cleaner, but depending on the compiler it can lead to emitting more machine code. This is entirely compiler-dependent, but the point of the WTF article is that in the second case the compiler would allocate a copy of string/integer value for each code snippet like that and in the first case it would do so only once per program.

提交回复
热议问题