Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A series of optimizations to improve performance of `String#to_utf16`: * Remove branches for impossible codepoints. `each_char` already excludes invalid codepoints, so we only have to handle the encoding as one or two UInt16. * Drop `ascii_only?` branch. The performance benefit is questionable because `ascii_only?` iterates the string. With optimizations to the regular loop, this special case doesn't provide much extra performance, so it's expendable. * Use pointer appender to avoid bounds checks on every slice assignment. It also improves convenience. * Use wrapping math operators. These operations cannot overflow, so we can use the unsafe variants for better performance.
- Loading branch information