HN Top New Show Ask Jobs

settings

Theme

Hand Mode

Feed

Comment by dkjaudyeqooe

Comment by dkjaudyeqooe a day ago

0 replies

View on Hacker News

A cleaner, faster way to implement this sort of thing is to use the "labels as values" extension if using GCC or Clang []. It avoids the switch statement and associated comparisons. Particularly useful if you're yielding inside nested loops (which IMHO is one of the most useful applications of coroutines) or switch statements.

[] https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html