Rollup merge of #101391 - matthiaskrgr:perf0309, r=oli-obk
more clippy::perf fixes
This commit is contained in:
commit
e4534fe6fe
6 changed files with 11 additions and 19 deletions
|
@ -842,7 +842,7 @@ pub trait LintContext: Sized {
|
||||||
if let Some(positional_arg_to_replace) = position_sp_to_replace {
|
if let Some(positional_arg_to_replace) = position_sp_to_replace {
|
||||||
let name = if is_formatting_arg { named_arg_name + "$" } else { named_arg_name };
|
let name = if is_formatting_arg { named_arg_name + "$" } else { named_arg_name };
|
||||||
let span_to_replace = if let Ok(positional_arg_content) =
|
let span_to_replace = if let Ok(positional_arg_content) =
|
||||||
self.sess().source_map().span_to_snippet(positional_arg_to_replace) && positional_arg_content.starts_with(":") {
|
self.sess().source_map().span_to_snippet(positional_arg_to_replace) && positional_arg_content.starts_with(':') {
|
||||||
positional_arg_to_replace.shrink_to_lo()
|
positional_arg_to_replace.shrink_to_lo()
|
||||||
} else {
|
} else {
|
||||||
positional_arg_to_replace
|
positional_arg_to_replace
|
||||||
|
|
|
@ -1377,19 +1377,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
|
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
|
||||||
let keys_and_jobs = tcx
|
let keys_and_jobs = tcx.mir_keys(()).iter().filter_map(|&def_id| {
|
||||||
.mir_keys(())
|
let (encode_const, encode_opt) = should_encode_mir(tcx, def_id);
|
||||||
.iter()
|
if encode_const || encode_opt { Some((def_id, encode_const, encode_opt)) } else { None }
|
||||||
.filter_map(|&def_id| {
|
});
|
||||||
let (encode_const, encode_opt) = should_encode_mir(tcx, def_id);
|
for (def_id, encode_const, encode_opt) in keys_and_jobs {
|
||||||
if encode_const || encode_opt {
|
|
||||||
Some((def_id, encode_const, encode_opt))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
for (def_id, encode_const, encode_opt) in keys_and_jobs.into_iter() {
|
|
||||||
debug_assert!(encode_const || encode_opt);
|
debug_assert!(encode_const || encode_opt);
|
||||||
|
|
||||||
debug!("EntryBuilder::encode_mir({:?})", def_id);
|
debug!("EntryBuilder::encode_mir({:?})", def_id);
|
||||||
|
|
|
@ -1393,7 +1393,7 @@ impl<'a> Resolver<'a> {
|
||||||
|
|
||||||
// If only some candidates are accessible, take just them
|
// If only some candidates are accessible, take just them
|
||||||
if !candidates.iter().all(|v: &ImportSuggestion| !v.accessible) {
|
if !candidates.iter().all(|v: &ImportSuggestion| !v.accessible) {
|
||||||
candidates = candidates.into_iter().filter(|x| x.accessible).collect();
|
candidates.retain(|x| x.accessible)
|
||||||
}
|
}
|
||||||
|
|
||||||
candidates
|
candidates
|
||||||
|
|
|
@ -429,7 +429,7 @@ mod cgroups {
|
||||||
Some(b"") => Cgroup::V2,
|
Some(b"") => Cgroup::V2,
|
||||||
Some(controllers)
|
Some(controllers)
|
||||||
if from_utf8(controllers)
|
if from_utf8(controllers)
|
||||||
.is_ok_and(|c| c.split(",").any(|c| c == "cpu")) =>
|
.is_ok_and(|c| c.split(',').any(|c| c == "cpu")) =>
|
||||||
{
|
{
|
||||||
Cgroup::V1
|
Cgroup::V1
|
||||||
}
|
}
|
||||||
|
|
|
@ -2367,9 +2367,9 @@ pub(crate) fn get_filtered_impls_for_reference<'a>(
|
||||||
let Some(v) = shared.cache.impls.get(&def_id) else { return (Vec::new(), Vec::new(), Vec::new()) };
|
let Some(v) = shared.cache.impls.get(&def_id) else { return (Vec::new(), Vec::new(), Vec::new()) };
|
||||||
// Since there is no "direct implementation" on the reference primitive type, we filter out
|
// Since there is no "direct implementation" on the reference primitive type, we filter out
|
||||||
// every implementation which isn't a trait implementation.
|
// every implementation which isn't a trait implementation.
|
||||||
let traits: Vec<_> = v.iter().filter(|i| i.inner_impl().trait_.is_some()).collect();
|
let traits = v.iter().filter(|i| i.inner_impl().trait_.is_some());
|
||||||
let (synthetic, concrete): (Vec<&Impl>, Vec<&Impl>) =
|
let (synthetic, concrete): (Vec<&Impl>, Vec<&Impl>) =
|
||||||
traits.into_iter().partition(|t| t.inner_impl().kind.is_auto());
|
traits.partition(|t| t.inner_impl().kind.is_auto());
|
||||||
|
|
||||||
let (blanket_impl, concrete): (Vec<&Impl>, _) =
|
let (blanket_impl, concrete): (Vec<&Impl>, _) =
|
||||||
concrete.into_iter().partition(|t| t.inner_impl().kind.is_blanket());
|
concrete.into_iter().partition(|t| t.inner_impl().kind.is_blanket());
|
||||||
|
|
|
@ -312,7 +312,7 @@ pub(super) fn write_shared(
|
||||||
if line.starts_with(&prefix) {
|
if line.starts_with(&prefix) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if line.ends_with(",") {
|
if line.ends_with(',') {
|
||||||
ret.push(line[..line.len() - 1].to_string());
|
ret.push(line[..line.len() - 1].to_string());
|
||||||
} else {
|
} else {
|
||||||
// No comma (it's the case for the last added crate line)
|
// No comma (it's the case for the last added crate line)
|
||||||
|
|
Loading…
Add table
Reference in a new issue