After years of working on parsers I write expressions like this mechanically: unsigned((ch | ‘ ‘) - ‘a’) < 26 ... and forget that this isn’t obvious.
-
-
Typically the character will be sign-extended and the result will be branched upon, so you get or+sub+cmp+ja which is probably optimal. The codegen for naive version is highly dependent on the compiler - likely way worse for MSVC
-
> likely way worse for MSVC After doing enough godbolt compares between clang/gcc/msvc, I've found this to almost always be the case. (Just tested--with /O2, msvc has two jumps). I'm still trying to figure out what clang is doing with the naive one.
Keskustelun loppu
Uusi keskustelu -
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.