On Sun, 1 Feb 2004, Andrew Dunstan wrote:

> As for the test being outside the "if" statement, it is true that that
> might waste a few cycles, but it hardly matters.

The cycles are not important. My "fix" wasn't the most optimized either if
one should count cycles. It was terminating the string twice in some
cases. That I thought about and came to the conclusion that it was not
important.  That I didn't rewrite the strncmp() to strcmp() is strange to
me, the length is obviously not needed. Good thing you looked at it.

> Personally, I would prefer to replace the if statement with this:
>     if (c == EOF || c == '\n')
>     {
>         *buf = '\0';
>         return;
>     }
> and then it wouldn't be an issue at all, but I know some people don't 
> like early function returns - is there a general postgres style rule 

I don't know what the style rules say. I have nothing against early
returns if used with grace. Early exits for odd cases, before the main
part of the function, just helps readability if you ask me. On the other
hand it does not matter since the correct is always to use whatever style
the rest of the program uses.

/Dennis Björklund

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

Reply via email to