`"\r".getBytes(Charsets.UTF_8)[0]` is a really expensive call. It goes through the charset codecs.
Just do a ` bytes[offset + numBytes -1] == '\r'`.