Skip to content

Commit

Permalink
Avoid unnecessary checks when calling readCodePointValue on Buffer (#343
Browse files Browse the repository at this point in the history
)

Improves performance by ~10%
  • Loading branch information
fzhinkin authored Jun 12, 2024
1 parent 80cbdd8 commit e0d5fa9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/common/src/Utf8.kt
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ public fun Source.readString(byteCount: Long): String {
*/
@OptIn(InternalIoApi::class)
public fun Source.readCodePointValue(): Int {
if (this is Buffer) {
return commonReadUtf8CodePoint()
}
require(1)

val b0 = buffer[0].toInt()
Expand Down

0 comments on commit e0d5fa9

Please sign in to comment.