mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Use Vec::with_capacity()
as possible
This commit is contained in:
parent
0da4dd009e
commit
f4b80394d7
@ -359,7 +359,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
|
||||
}
|
||||
simplified.push(simple_negated);
|
||||
}
|
||||
let mut improvements = Vec::new();
|
||||
let mut improvements = Vec::with_capacity(simplified.len());
|
||||
'simplified: for suggestion in &simplified {
|
||||
let simplified_stats = terminal_stats(suggestion);
|
||||
let mut improvement = false;
|
||||
|
@ -724,7 +724,7 @@ fn is_panic_block(block: &Block<'_>) -> bool {
|
||||
|
||||
fn check_match_ref_pats(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr: &Expr<'_>) {
|
||||
if has_only_ref_pats(arms) {
|
||||
let mut suggs = Vec::new();
|
||||
let mut suggs = Vec::with_capacity(arms.len() + 1);
|
||||
let (title, msg) = if let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, ref inner) = ex.kind {
|
||||
let span = ex.span.source_callsite();
|
||||
suggs.push((span, Sugg::hir_with_macro_callsite(cx, inner, "..").to_string()));
|
||||
|
@ -101,7 +101,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Shadow {
|
||||
}
|
||||
|
||||
fn check_fn<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl<'_>, body: &'tcx Body<'_>) {
|
||||
let mut bindings = Vec::new();
|
||||
let mut bindings = Vec::with_capacity(decl.inputs.len());
|
||||
for arg in iter_input_pats(decl, body) {
|
||||
if let PatKind::Binding(.., ident, _) = arg.pat.kind {
|
||||
bindings.push((ident.name, ident.span))
|
||||
|
Loading…
Reference in New Issue
Block a user