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

后端 未结 6 1183
北海茫月
北海茫月 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:44

    Depending on the compiler and compiler options, initialization like this

    char data_string[15] = "data data data";
    

    results in a lot of move instructions to copy the literal data to stack.

    Calling strcpy requires less instructions.

    Doing this kind of thing all over a large codebase can increase the binary size significantly.

    And of course, he was not spending his time on adding any value.

提交回复
热议问题