Adopted paren-cond ternary operator style

So:

  x = (cond) ? yes : no;

Where there are always parentheses around the condition, even if not
required for disambiguity. Additional parentheses are always allowed,
but the parenthesized condition helps signal that a ternary operator is
coming earlier in the expression.

This style has grown on me as I think it helps code readability. It
reminds me of the required parentheses for if/while statements.

Might as well adopt codebase-wide.
This commit is contained in:
Christopher Haster
2024-01-20 21:40:00 -06:00
parent 76715ced4a
commit 6fc040db1a
10 changed files with 286 additions and 282 deletions
+1 -1
View File
@@ -187,7 +187,7 @@ static inline int32_t lfs_sclamp32(int32_t a, int32_t min, int32_t max) {
// Absolute value of signed numbers
static inline int32_t lfs_abs32(int32_t a) {
return a < 0 ? -a : a;
return (a < 0) ? -a : a;
}
// TODO how many of these do we actually need