Conversation
|
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
src/librustc_resolve/lib.rs
Outdated
There was a problem hiding this comment.
hm, why is this offset by 1 but the next one not?
There was a problem hiding this comment.
This preserves the existing logic; self.ribs[ValueNS] was popped once more after the loop.
There was a problem hiding this comment.
Please, keep the old obvious logic (pops are symmetric with pushes above), unless you have benchmarks.
There was a problem hiding this comment.
@petrochenkov truncating is faster - the more elements to pop, the faster it becomes.
There was a problem hiding this comment.
I know that it's faster, I meant that it doesn't matter that it's faster, because the speed up is unnoticeable in the general picture. In this case readability/simplicity is very much preferable.
(By benchmarks I mean e.g. benchmark showing that this specific code is hot and takes a significant percent of resolve time.)
There was a problem hiding this comment.
Unfortunately I don't have a Linux rig to do perf runs :/. I can revert to the original code if you don't think this piece of code is hot enough.
src/librustc_resolve/macros.rs
Outdated
There was a problem hiding this comment.
No real need for the saturating_sub here since we've already checked if traits is empty (it's not)
There was a problem hiding this comment.
I'd say there's no real need to pollute code with reserves/capacities unless there are benchmarks.
There was a problem hiding this comment.
(Also, this specific code is being removed in #54271.)
There was a problem hiding this comment.
@petrochenkov push loops with specified capacity are always faster than with an empty Vec.
src/librustc_resolve/macros.rs
Outdated
There was a problem hiding this comment.
This is plausibly a change in behavior?
There was a problem hiding this comment.
Whoops, I misread it as an if let; this might be the reason behind the error (I'll check on my testing rig before updating).
|
Please, keep |
src/librustc_resolve/lib.rs
Outdated
There was a problem hiding this comment.
I think you can just use ["this", "my"].contains(&*item_str.as_str()) here.
There was a problem hiding this comment.
Almost; ["this", "my"].contains(&&*item_str.as_str()).
eef2fe9 to
89c20b7
Compare
|
@petrochenkov I fixed the test error (it was the one I expected), rolled back |
|
Thanks! |
|
📌 Commit 89c20b7 has been approved by |
Cleanup resolve - improve/remove allocations - `truncate` instead of `pop`ping in a loop - improve common patterns
Cleanup resolve - improve/remove allocations - `truncate` instead of `pop`ping in a loop - improve common patterns
Rollup of 7 pull requests Successful merges: - #54300 (Updated RELEASES.md for 1.30.0) - #55013 ([NLL] Propagate bounds from generators) - #55071 (Fix ICE and report a human readable error) - #55144 (Cleanup resolve) - #55166 (Don't warn about parentheses on `match (return)`) - #55169 (Add a `copysign` function to f32 and f64) - #55178 (Stabilize slice::chunks_exact(), chunks_exact_mut(), rchunks(), rchunks_mut(), rchunks_exact(), rchunks_exact_mut())
truncateinstead ofpopping in a loop