Skip to content

Commit e0d5fa9

Browse files
authored
Avoid unnecessary checks when calling readCodePointValue on Buffer (#343)
Improves performance by ~10%
1 parent 80cbdd8 commit e0d5fa9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

core/common/src/Utf8.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ public fun Source.readString(byteCount: Long): String {
260260
*/
261261
@OptIn(InternalIoApi::class)
262262
public fun Source.readCodePointValue(): Int {
263+
if (this is Buffer) {
264+
return commonReadUtf8CodePoint()
265+
}
263266
require(1)
264267

265268
val b0 = buffer[0].toInt()

0 commit comments

Comments
 (0)