Skip to content

Comment on When static makes your C code 10 times fasterparent

Comments

The only real case I use switch fallthrough for is when you have two cases with the same code, e.g.:

  switch (foo) {
  case 1:
  case 2:
    /* common body */
    break;
  case 3:
    /* body 3 */
    break;
  }
It's not cognitively hard to make an empty case body fallthrough to the next run, but include an implicit break at the end of every nontrivial body.

Supporting Duff's Device is not a compelling feature to support--irreducible loops are basically going to destroy any hope of optimization you might accrue.

The only real case

which is probably the case in 90% of all my switch'es. Worst use of a time machine ever.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.