Uh oh!
There was an error while loading. Please reload this page.
use char instead of &str for single char patterns - #69481
Conversation
ecstatic-morse
left a comment
There was a problem hiding this comment.
r=me after removing unnecessary escapes.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
b974a81 to
8ceb909Compareecstatic-morse
commented
Feb 26, 2020
@bors r+ rollup=always |
bors
commented
Feb 26, 2020
📌 Commit 8ceb9096ac72bab8b5566f22645c16e84634603f has been approved by |
Dylan-DPC-zz
commented
Feb 26, 2020
failed in rollup |
Rollup of 4 pull requests Successful merges: - #69439 (resolve: `lifetimes.rs` -> `late/lifetimes.rs`) - #69473 (update llvm to silence gcc 9 warnings) - #69479 (clarify operator precedence) - #69480 (Clean up E0373 explanation) Failed merges: - #69481 (use char instead of &str for single char patterns) - #69496 (use find(x) instead of filter(x).next()) r? @ghost
petrochenkov
commented
Feb 27, 2020
#41993 was fixed, but I still think this replacement is ideologically wrong. |
matthiaskrgr
commented
Feb 27, 2020
When running these benchmarks that I found via the discussion you linked #![feature(test)]externcrate test;usecrate::test::black_box;usecrate::test::Bencher;fnmain(){println!("Hello, world!");}#[bench]fnstarts_with_char(b:&mutBencher){let text = black_box("kdjsfhlakfhlsghlkvcnljknfqiunvcijqenwodind");
b.iter(|| {for _ in0..1024{black_box(text.starts_with('k'));}})}#[bench]fnstarts_with_str(b:&mutBencher){let text = black_box("kdjsfhlakfhlsghlkvcnljknfqiunvcijqenwodind");
b.iter(|| {for _ in0..1024{black_box(text.starts_with("k"));}})}#[bench]fnends_with_char(b:&mutBencher){let text = black_box("kdjsfhlakfhlsghlkvcnljknfqiunvcijqenwodind");
b.iter(|| {for _ in0..1024{black_box(text.ends_with('k'));}})}#[bench]fnends_with_str(b:&mutBencher){let text = black_box("kdjsfhlakfhlsghlkvcnljknfqiunvcijqenwodind");
b.iter(|| {for _ in0..1024{black_box(text.ends_with("k"));}})}, char is consistently faster for me with default optimization levels: |
petrochenkov
commented
Feb 27, 2020
If this is a perf improvement now, rather than just a stylistic change, then it should be ok. |
bors
commented
Feb 27, 2020
☔ The latest upstream changes (presumably #69507) made this pull request unmergeable. Please resolve the merge conflicts. |
8ceb909 to
7c84ba1Comparematthiaskrgr
commented
Feb 27, 2020
rebased |
matthiaskrgr
commented
Feb 28, 2020
r? @petrochenkov or @ecstatic-morse |
Dylan-DPC-zz
commented
Feb 28, 2020
@bors r=ecstatic-morse |
bors
commented
Feb 28, 2020
📌 Commit 7c84ba1 has been approved by |
Rollup of 10 pull requests Successful merges: - #68989 (Update RELEASES.md for 1.42.0) - #69340 (instantiate_value_path: on `SelfCtor`, avoid unconstrained tyvars) - #69384 (parser: `token` -> `normalized_token`, `nonnormalized_token` -> `token`) - #69452 (typeck: use `Pattern` obligation cause more for better diagnostics) - #69481 (use char instead of &str for single char patterns) - #69522 (error_derive_forbidden_on_non_adt: be more graceful) - #69538 (Stabilize `boxed_slice_try_from`) - #69539 (late resolve, visit_fn: bail early if there's no body.) - #69541 (Remove unneeded calls to format!()) - #69547 (remove redundant clones, references to operands, explicit boolean comparisons and filter(x).next() calls.) Failed merges: r? @ghost
No description provided.