https://github.com/nginx/nginx/blob/7587778a33bea0ce6f203a8c...
There are several points to note: This trick only works if the architecture supports unaligned memory access. Macros are used instead of functions, so you don't have to rely on the compiler to do inlining. The shifts and ors should get optimized out by the compiler. I once tried something similar in C#, but sadly the JIT doesn't do that optimization.
That method does look better. My idea assumes that the method has already been checked to see if it is a valid method, which has its own cost. Otherwise, POSABC would be parsed as POST. Their method does that more or less on the fly.
Presumably then it's relying on undefined behaviour.
https://stackoverflow.com/a/47622343/
https://stackoverflow.com/a/28895321/
https://blog.quarkslab.com/unaligned-accesses-in-cc-what-why...