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

后端 未结 6 765
深忆病人
深忆病人 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:21

    Is there any evidence that most (or any) compilers would generate better (e.g. more efficient) code?

    Not much, unless you look at the actual generated assembly of an actual, specific compiler on a specific platform with some specific optimization settings.

    This was probably worth worrying about decades ago (when ZLib has been written), but certainly not nowadays, unless you found, by real profiling, that this removes a bottleneck from your code.

提交回复
热议问题