Skip to content

Improve size_hint bounds for DecodeUtf16 iterator #88763

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 2 commits into from

Conversation

steffahn
Copy link
Member

@steffahn steffahn commented Sep 8, 2021

If at most 2 u16s make up one item in the iterator, then there has to be a minimum of len + 1 / 2 elements for an odd-numbered iterator. In other words, the best lower bound would be determined by rounding up.

Edit: I noticed #88762 while creating a PR including just bea5cd1. So now, I’ve added a commit that fixes #88762 as-well.

@rust-highfive
Copy link
Contributor

r? @scottmcm

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 8, 2021
@steffahn
Copy link
Member Author

steffahn commented Sep 8, 2021

There’s the option of also inspecting buf to create a more accurate size_hint.

@steffahn steffahn force-pushed the better_decode_size_hint branch from 658184c to fa5e283 Compare September 8, 2021 21:18
@steffahn
Copy link
Member Author

steffahn commented Sep 8, 2021

Also missing tests. I’m going to create an alternative version that does inspect buf, for comparison.

@rustbot label S-waiting-on-author -S-waiting-on-review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 8, 2021
@steffahn
Copy link
Member Author

steffahn commented Sep 8, 2021

I’m going to create an alternative version that does inspect buf, for comparison.

9868947 might work. I won’t continue this before tomorrow.

@the8472 the8472 added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Sep 21, 2021
@crlf0710
Copy link
Member

crlf0710 commented Oct 9, 2021

@steffahn Ping from triage, any updates on this?

@JohnCSimon
Copy link
Member

Triage:
@steffahn Closing this as inactive because there were no commits for over a month. Please feel free to reopen when you are ready to continue on this. Thank you.

@rustbot +S-Inactive

@JohnCSimon JohnCSimon closed this Oct 24, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 30, 2022
…16_size_hint, r=dtolnay

Make `char::DecodeUtf16::size_hist` more precise

New implementation takes into account contents of `self.buf` and rounds lower bound up instead of down.

Fixes rust-lang#88762
Revival of rust-lang#88763
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 31, 2022
…16_size_hint, r=dtolnay

Make `char::DecodeUtf16::size_hist` more precise

New implementation takes into account contents of `self.buf` and rounds lower bound up instead of down.

Fixes rust-lang#88762
Revival of rust-lang#88763
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect upper bound for size_hint of char::DecodeUtf16
7 participants