Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Buffer indexOf with Limit #1587

Open
yschimke opened this issue Feb 1, 2025 · 3 comments
Open

Add Buffer indexOf with Limit #1587

yschimke opened this issue Feb 1, 2025 · 3 comments

Comments

@yschimke
Copy link
Collaborator

yschimke commented Feb 1, 2025

From square/okhttp#8665

Ideally we would have

override fun indexOf(bytes: ByteString, fromIndex: Long, toIndex: Long): Long
@JakeWharton
Copy link
Collaborator

Might be better to do #1208 and then all APIs get a free limiter. You can do either limit(1024).indexOf(..) or peek().limit(1024).indexOf(..) to not consume.

@yschimke
Copy link
Collaborator Author

yschimke commented Feb 1, 2025

Yep, particularly since @swankjesse publicly promised to rush it. 😁

To celebrate this fun coincidence I shall rush this new API.

@JakeWharton
Copy link
Collaborator

I have it on a branch, not that it's all that complicated. The sole impediment was that OkHttp needs to know when you hit the limit. And I can't remember if it also needs a callback when someone closes. The API was getting messy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants