lean4
lean4 copied to clipboard
Replace `String.fromUtf8Unchecked` with `String.fromUtf8?`
Unlike String.fromUtf8Unchecked, this one should check for valid UTF-8. In fact, since we have to decode the string anyway to figure out its character length, we might as well remove the former function.
However all String.Pos-based functions immediately work for an Utf8Unchecked without any extra decoding because the UTF8 size is just the ByteArray size and can be cached from the start.
I'm not quite sure what you mean. String eagerly, always caches the number of code points.
My bad, indeed there is an eager utf8_strlen call in the constructor and the "unchecked" is not any faster.