Declare an object inside or outside a loop?

前端 未结 16 787
广开言路
广开言路 2020-12-07 17:15

Is there any performance penalty for the following code snippet?

for (int i=0; i         


        
16条回答
  •  無奈伤痛
    2020-12-07 17:57

    In today's compilers, no. I declare objects in the smallest scope I can, because it's a lot more readable for the next guy.

提交回复
热议问题