[FFmpeg-devel] [PATCH 2/4] avcodec/xpm: Minor speed increase for mod_strcspn() {string, reject}==0

Moritz Barsnick barsnick at gmx.net
Wed Feb 24 15:56:17 EET 2021


On Mon, Feb 22, 2021 at 20:32:14 -0800, Jose Da Silva wrote:
> -    for (i = 0; string && string[i]; i++) {
> +    if (string == 0)

"if (!string)" is the preferred style for pointers.

But I don't see the advantage - isn't the loop interrupted immediately
anyway if string == NULL? (Same for the other loop you changed.)

Inside the loops, the additional checks for validity of "string"
seem redundant either way, though:

  while ( string && string[i] && string[i] != '\n' )

Moritz


More information about the ffmpeg-devel mailing list