Re:Going Faster by Duplicating Code
by ladberg on Wednesday October 11, 2023 @10:36AM
(#37844946)
I've used this before for memcpy with arbitrary values that are likely to be one of a small set of known small sizes.
Calling memcpy with an arbitrary value always has to call out to libc but a specific value can be inlined into a single instruction or two for smaller values, so you can have an if-else chain or switch with a few common ones for your program and it's a noticeable speedup.
Calling memcpy with an arbitrary value always has to call out to libc but a specific value can be inlined into a single instruction or two for smaller values, so you can have an if-else chain or switch with a few common ones for your program and it's a noticeable speedup.