On 26 Jan 2016, at 12:17, Jacob Erlbeck jerlbeck@sysmocom.de wrote:
On 26.01.2016 11:22, Holger Freyther wrote:
On 22 Jan 2016, at 16:46, suraev@alumni.ntnu.no wrote:
+/* we assume that x have at least 1 non-b bit */ +static inline unsigned _leading_bits(uint8_t x, bool b) +{
- if (b) {
if (x < 0x80) return 0;if (x < 0xC0) return 1;if (x < 0xE0) return 2;if (x < 0xF0) return 3;if (x < 0xF8) return 4;if (x < 0xFC) return 5;if (x < 0xFE) return 6;- } else {
if (x > 0x7F) return 0;if (x > 0x3F) return 1;if (x > 0x1F) return 2;if (x > 0xF) return 3;if (x > 7) return 4;if (x > 3) return 5;if (x > 1) return 6;- }
same coding style thing
In such cases, the readability would suffer when putting the returns in the next line. I'd rather right align the numbers after the '>', but YMMV.
sure or somemthing like case 0xff..0x80: return 0; case 0x7F..0xC0: return 1;
anyway, the above is okay and something we can argue with but if it is more than a "look-up table" then we should break the line.