News for hackers. Stuff that matters.
Re:Why I prefer objects over switch statements by mrmuagi on Friday February 22, 2019 @07:22PM (#19230518)
It's actually a big issue in any performance critical regions of code. I've come across this in both the network stack and the file system (user space and kernel).

Switches can sometimes be optimised away into O(1) using clever static compile time tricks, but if you rely on jump indirection you get branch misdirection penalties, or even worse for a ladder of if's, you are doing O(N) work (where N is number of cases).

Re:Why I prefer objects over switch statements by Scooty on Friday March 01, 2019 @05:55PM (#19286114)
Seems like the key is "performance critical regions of code". Yeah optimize code that is performance critical. Don't optimize the other 99%.
Re:Why I prefer objects over switch statements by mrmuagi on Monday March 04, 2019 @05:07PM (#19306066)
I agree with you, yeah. The problem is sometimes you have to go back to old code and optimise it, because today's performance expectations are higher than yesterdays -- whether because hardware has become more powerful or software is being pushed to its limits. So I'm a bit biased, thinking, "If only this was optimised day 1", but truthfully, recognising the requirements and reacting to the performance needs as they arise can be less wasteful than having ironclad performance requirements that won't be met or needed to be met.