Make `sample` a macro to eliminate function call overhead.