3 ms·
While there certainly are such cases, I think here it’s just about being proficient in a language. Pointers, referencing and dereferencing are the bread and but
by m_mueller 6y ago
While there certainly are such cases, I think here it’s just about being proficient in a language. Pointers, referencing and dereferencing are the bread and butter of any C code, and applying them in a way to reduce complexity is certainly something to strive for - if this isn’t readable then I’d argue the reader shouldn’t be touching the codebase anyways.
- andy_ppp 6y agoFortunately or unfortunately you don’t always get to decide who touches the code, so unless performance is a concern as it is in kernel development optimising like this in the day job will eventually lead people making mistakes. Basically I say be as explicit and clear as you dare, even at the cost of some CPU cycles.
- saagarjha 6y agoAdding extra dereferences is rarely performant. The example is written this way because it's more elegant, not because it's faster.
- metters 6y agoYou are right, for a c programmer this is bread and butter. The readability of the example would increase a lot with better named variables, however.