Use unsafe calls to c

There is substantial overhead involved with a safe call, that's easily much greater than the computation actually performed here.   And given that your helpers operate in a small constant time,  I don't see why you need a safe call.