diff options
| author | Patrick Walton <[email protected]> | 2011-04-22 10:19:22 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-04-22 10:19:57 -0700 |
| commit | 9ab9bd9cc2dc97c2acc26849dd24b8989b76ea32 (patch) | |
| tree | 7c28bafcfc4a765d11a3b769db55557f2f864f20 /src/comp/middle | |
| parent | Switch to binary search in codemap.lookup_pos (diff) | |
| download | rust-9ab9bd9cc2dc97c2acc26849dd24b8989b76ea32.tar.xz rust-9ab9bd9cc2dc97c2acc26849dd24b8989b76ea32.zip | |
rustc: Improve the efficiency of lookup_item_type() slightly
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/ty.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 5829c0be..59de7768 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -2484,17 +2484,17 @@ fn lookup_item_type(session.session sess, if (did._0 == sess.get_targ_crate_num()) { // The item is in this crate. The caller should have added it to the // type cache already; we simply return it. - check (cache.contains_key(did)); ret cache.get(did); } - if (cache.contains_key(did)) { - ret cache.get(did); + alt (cache.find(did)) { + case (some[ty_param_count_and_ty](?tpt)) { ret tpt; } + case (none[ty_param_count_and_ty]) { + auto tyt = creader.get_type(sess, tystore, did); + cache.insert(did, tyt); + ret tyt; + } } - - auto tyt = creader.get_type(sess, tystore, did); - cache.insert(did, tyt); - ret tyt; } |