-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Improve string literal unescaping #94316
Improve string literal unescaping #94316
Conversation
`scan_escape` currently has a fast path (for when the first char isn't '\\') and a slow path. This commit changes `scan_escape` so it only handles the slow path, i.e. the actual escaping code. The fast path is inlined into the two call sites. This change makes the code faster, because there is no function call overhead on the fast path. (`scan_escape` is a big function and doesn't get inlined.) This change also improves readability, because it removes a bunch of mode checks on the the fast paths.
The change looks big because `rustfmt` rearranges things, but the only real change is the inlining annotation.
Best reviewed one commit at a time. @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 44308dc with merge 237a467d69c269f182947a1c90a981529f0e1538... |
This won't benefit the benchmarks in rustc-perf much, the benefits are in other crates. Here are the instruction count results I got locally for
|
As for the relative importance of the two commits, here are
|
☀️ Try build successful - checks-actions |
Queued 237a467d69c269f182947a1c90a981529f0e1538 with parent e780264, future comparison URL. |
Finished benchmarking commit (237a467d69c269f182947a1c90a981529f0e1538): comparison url. Summary: This benchmark run shows 5 relevant improvements 🎉 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf. @bors rollup=never |
r? @petrochenkov @bors r+ |
📌 Commit 44308dc has been approved by |
I'm going to return this to rollup-able state, we see the result, it's localized to 2-3 crates and should be visible in a rollup, no need to merge this separately. |
⌛ Testing commit 44308dc with merge 6ac6b249df629dad06f915a563bc7073ef206bf6... |
💔 Test failed - checks-actions |
Network failures when accessing crates.io |
…unescaping, r=petrochenkov Improve string literal unescaping Some easy wins that affect a few popular crates. r? `@matklad`
…unescaping, r=petrochenkov Improve string literal unescaping Some easy wins that affect a few popular crates. r? ``@matklad``
Rollup of 9 pull requests Successful merges: - rust-lang#91795 (resolve/metadata: Stop encoding macros as reexports) - rust-lang#93714 (better ObligationCause for normalization errors in `can_type_implement_copy`) - rust-lang#94175 (Improve `--check-cfg` implementation) - rust-lang#94212 (Stop manually SIMDing in `swap_nonoverlapping`) - rust-lang#94242 (properly handle fat pointers to uninhabitable types) - rust-lang#94308 (Normalize main return type during mono item collection & codegen) - rust-lang#94315 (update auto trait lint for `PhantomData`) - rust-lang#94316 (Improve string literal unescaping) - rust-lang#94327 (Avoid emitting full macro body into JSON errors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Note: several of the affected crates, such as |
Some easy wins that affect a few popular crates.
r? @matklad