Hacker News new | ask | show | jobs
by lorenzhs 3476 days ago
That only works for compile time constants, though. With a power of two sized buffer you can just store the mask and decide how large you want your buffer to be at runtime.
2 comments

libdivide (http://libdivide.com) implements similar logic at runtime
You can also compute the optimization at runtime, same as the compiler does. Libtheora contains code for this, used for quantizing video data.