Do compilers produce better code for do-while loops versus other types of loops?

后端 未结 6 781
深忆病人
深忆病人 2020-12-08 01:48

There\'s a comment in the zlib compression library (which is used in the Chromium project among many others) which implies that a do-while loop in C generates "better&q

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 02:22

    This discussion of while vs. do efficiency is completely pointless in this case, as there is no body.

    while (Condition)
    {
    }
    

    and

    do
    {
    }
    while (Condition);
    

    are absolutely equivalent.

提交回复
热议问题