Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

10
  • 3
    Possible duplicate of Is micro-optimisation important when coding? Commented May 4, 2018 at 6:11
  • 3
    C++ doesn't have labelled breaks, therefore the canonical and accepted practice is to emulate them via goto, despite its bad reputation. Don't fear names - fear concepts. Commented May 4, 2018 at 6:24
  • 2
    @Akiva: so did you actually measure the performance difference? And just because you have heard "goto" is an acceptable way of breaking out of a nested loop does not imply the alternative of introducing a function with a clear and concise name would not be more readable. Commented May 4, 2018 at 6:29
  • 3
    @Akiva: benchmarking this is pretty simple, you don't need special tools or skills: set up a small program which calls this function with some test data in a loop several times (maybe several million times), and measure the running time with a stopwatch. Do the same with the cleaned-up code. I bet the difference will be negligible (of course, don't forget to use compiler optimizations). Commented May 4, 2018 at 6:41
  • 5
    Why are you reinventing the wheel? Commented May 4, 2018 at 17:30