Optimize offset calculations

Since the Howl API operates on a character level (code points), and
UTF8 is used as the internal format, we end up doing lots of offset
calculations for multi-byte buffers. We now maintain a cache of
recent offsets used for cutting down on string scanning.