Skip to content

Optimize core::unicode::printable. #139540

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

reitermarkus
Copy link
Contributor

Follow-up to #138024, which apparently still wasn't enough to fully optimize char::escape_debug.

Again, this only seems to make a difference on embedded targets, e.g. thumbv7m-none-eabi.

@rustbot
Copy link
Collaborator

rustbot commented Apr 8, 2025

r? @workingjubilee

rustbot has assigned @workingjubilee.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 8, 2025
@rust-log-analyzer

This comment has been minimized.

@reitermarkus reitermarkus force-pushed the optimize-char-printable branch from 1a57f45 to 9109550 Compare April 8, 2025 17:26
@reitermarkus
Copy link
Contributor Author

r? libs

@reitermarkus
Copy link
Contributor Author

r? libs

@reitermarkus
Copy link
Contributor Author

r? libs

@rustbot rustbot assigned jhpratt and unassigned workingjubilee May 23, 2025
@jhpratt
Copy link
Member

jhpratt commented May 24, 2025

Not sure if he's a libs reviewer, but Manish is probably the best person to review anything Unicode.

r? @Manishearth

@rustbot rustbot assigned Manishearth and unassigned jhpratt May 24, 2025
@Manishearth
Copy link
Member

This appears to be an optimization. It doesn't seem to be doing anything super Unicodey; it appears to be doing some byte lookup optimizations. I don't think I have the bandwidth to review this right now.

I'm wary about the unsafe here. If this is going to have unsafe, it should be thoroughly documented. At the moment there's no clarity on what these functions or these constants actually are, which isn't great but it's "not great" in an okay way because there's no unsafe.

I'd also suggest rewriting it so that the actual Rust code does not need to be autogenerated, just some constants and a small match for the large parts.

@Manishearth Manishearth removed their assignment May 25, 2025
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@reitermarkus reitermarkus force-pushed the optimize-char-printable branch from 0c06957 to 9e66027 Compare May 30, 2025 17:24
@rust-log-analyzer

This comment has been minimized.

@reitermarkus reitermarkus force-pushed the optimize-char-printable branch 2 times, most recently from 36cd81d to 2acf703 Compare May 30, 2025 22:18
@reitermarkus
Copy link
Contributor Author

r? @jhpratt

@jhpratt
Copy link
Member

jhpratt commented May 31, 2025

I really am not familiar with this kind of code; I passed off for a reason.

r? libs

@rustbot rustbot assigned joboet and unassigned jhpratt May 31, 2025
@reitermarkus reitermarkus force-pushed the optimize-char-printable branch from 2acf703 to 2d8509c Compare May 31, 2025 19:32
@reitermarkus
Copy link
Contributor Author

@jhpratt, to be fair, I am also only slightly familiar with the code. 😄

I know what it does, but not how the underlying Unicode logic works. This PR doesn't change the logic, it only refactors the code to make it easier to reason about why the bounds checks are unneeded.

@reitermarkus reitermarkus force-pushed the optimize-char-printable branch from 2d8509c to 66ada05 Compare June 1, 2025 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

9 participants