diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-04-02 16:20:02 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-04-19 11:53:33 -0700 |
| commit | 4c29b4cb93ee090a22d27faf4e700bfc2364ebc5 (patch) | |
| tree | 081bb9803f1887746caa5e510916a6ed3a588d59 /src/libsyntax/util | |
| parent | 53f54dda60a769fa6b3d325f5787134bc9d90c6b (diff) | |
| download | rust-4c29b4cb93ee090a22d27faf4e700bfc2364ebc5.tar.gz rust-4c29b4cb93ee090a22d27faf4e700bfc2364ebc5.zip | |
librustc: Optimize metadata::decoder::item_name.
Diffstat (limited to 'src/libsyntax/util')
| -rw-r--r-- | src/libsyntax/util/interner.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 75bcac1b163..cda1c6c0df3 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -16,6 +16,7 @@ #[macro_escape]; use core::prelude::*; +use core::cmp::Equiv; use core::hashmap::HashMap; pub struct Interner<T> { @@ -67,6 +68,14 @@ pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> { fn get(&self, idx: uint) -> T { self.vect[idx] } fn len(&self) -> uint { let vect = &*self.vect; vect.len() } + + fn find_equiv<Q:Hash + IterBytes + Equiv<T>>(&self, val: &Q) + -> Option<uint> { + match self.map.find_equiv(val) { + Some(v) => Some(*v), + None => None, + } + } } /* Key for thread-local data for sneaking interner information to the |
