Using black magic to make a fast circular buffer