square / okio

A modern I/O library for Android, Java, and Kotlin Multiplatform.
https://square.github.io/okio/
Apache License 2.0
8.81k stars 1.18k forks source link

Update Buffer.kt #1531

Closed GeorgCantor closed 1 month ago

GeorgCantor commented 1 month ago

Reduced Complexity: The previous nested if statements for calculating the width were replaced with a single when expression.

JakeWharton commented 1 month ago

This change slows down the code, changing it from a biased binary search to a linear scan. We're actually going to change it to a constant time operation, I just haven't gotten around to it yet. See https://www.romainguy.dev/posts/2024/down-another-rabbit-hole/