]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #90746 - nnethercote:opt-pattern-matching, r=Nadrieril
authorbors <bors@rust-lang.org>
Thu, 11 Nov 2021 18:26:49 +0000 (18:26 +0000)
committerbors <bors@rust-lang.org>
Thu, 11 Nov 2021 18:26:49 +0000 (18:26 +0000)
Optimize pattern matching

These commits speed up the `match-stress-enum` benchmark, which is very artificial, but the changes are simple enough that it's probably worth doing.

r? `@Nadrieril`

compiler/rustc_mir_build/src/thir/pattern/usefulness.rs

index d959d2f7f6f3f9ca292c8cd072b0799bf5c06486..067b0506e308cd2353a4c99e8458f2d7b3319172 100644 (file)
@@ -797,7 +797,7 @@ fn is_useful<'p, 'tcx>(
         return ret;
     }
 
-    assert!(rows.iter().all(|r| r.len() == v.len()));
+    debug_assert!(rows.iter().all(|r| r.len() == v.len()));
 
     let ty = v.head().ty();
     let is_non_exhaustive = cx.is_foreign_non_exhaustive_enum(ty);