3 ms·
With the const-everywhere approach, the code reads like it's in an SSA format and is dataflow-oriented. As an extreme example, the "len - 1" expression can be s
by bluetomcat 5y ago
With the const-everywhere approach, the code reads like it's in an SSA format and is dataflow-oriented. As an extreme example, the "len - 1" expression can be substituted with yet another const variable:
const size_t len = strlen(s);
if (len > 0)
{
const size_t len_minus_one = len - 1;
s[len_minus_one] = '\0';
}
The additional const "variables" also add another layer of self-documentation by virtue of their names.