Skip to content

Commit 08b49a5

Browse files
committed
Reformulate an assert in ty::tag_variants
This was doing a redundant hashmap lookup. Removing the redundancy trims 5% (2.8s) off rustc's compile time
1 parent cfaa0f4 commit 08b49a5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/comp/middle/ty.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,8 +2702,13 @@ fn tag_variants(&ctxt cx, &ast::def_id id) -> vec[variant_info] {
27022702
if (cx.sess.get_targ_crate_num() != id._0) {
27032703
ret creader::get_tag_variants(cx, id);
27042704
}
2705-
assert (cx.items.contains_key(id._1));
2706-
alt (cx.items.get(id._1)) {
2705+
auto item = alt (cx.items.find(id._1)) {
2706+
case (some(?i)) { i }
2707+
case (none) {
2708+
cx.sess.bug("expected to find cached node_item")
2709+
}
2710+
};
2711+
alt (item) {
27072712
case (ast_map::node_item(?item)) {
27082713
alt (item.node) {
27092714
case (ast::item_tag(?variants, _)) {

0 commit comments

Comments
 (0)