The Performance Impact of C++'s `final` Keyword
81–90 of 385 posts
Re: The Performance Impact of C++'s `final` Keyword
#82Re: The Performance Impact of C++'s `final` Keyword
#83Re: The Performance Impact of C++'s `final` Keyword
#84Re: The Performance Impact of C++'s `final` Keyword
#85Earlier quoted context omitted.
Updates to languages (don't know where C# is on this) have different types of switch statements that eliminate the `break` problem. For example, with java there's enhanced switch that looks like this var val = switch(foo) { case 1, 2, 3 -> bar; case 4 -> baz; default -> { yield bat(); } } The C style switch break stuff is definitely a language mistake.
C# has both switch expressions like this and also break statements are not optional in traditional switch statements so it actually solves both problems. You can't get too clever with switch statements in C#. However most languages have pretty permissive switch statements just like C.
Re: The Performance Impact of C++'s `final` Keyword
#86Re: The Performance Impact of C++'s `final` Keyword
#87Re: The Performance Impact of C++'s `final` Keyword
#88Earlier quoted context omitted.
Even if one of these constructs is faster it doesn't matter 99% of the time. Writing well structured readable code is typically far more important than making it twice as fast. And those times can rarely be predicted beforehand, so you should mostly not worry about it until you see real performance problems.
The counter-argument to this is if you are building something that is in the critical path of an application (for example, parsing HTTP in a web server), you need to be performance-minded from the beginning because design decisions lead to design decisions. If you are building something in the critical path of the application, the best thing to do is build it from the ground up measuring the performance of what you h…