2 ms·
Putty has coroutines coded exactly that way -- one huge file, with a case for each spot that does something that could block. A coworker said, "I love it, and I
by ncmncm 6y ago
Putty has coroutines coded exactly that way -- one huge file, with a case for each spot that does something that could block. A coworker said, "I love it, and I hate myself for loving it."
Clang, and Gcc up to 8, will turn a switch statement with small numeric alternatives into a bitmask constant and a test against the bits. So,
switch (c)
case'a':case'e':
case'i':case'o':case'u':
return true;
return false;
turns into a range check and a "bt" instruction, effectively
!!((1 << c-'a') & 0x40111)
BUT: Gcc-9 and Gcc-10 both generate, instead,
a jump table 168 bytes long. Microbenchmark
results notwithstanding, this seems like a
radical pessimization.