]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/cache.rs
Rollup merge of #100163 - TaKO8Ki:remove-unnecessary-string-search, r=wesleywiser
[rust.git] / src / bootstrap / cache.rs
index 72de0a090af2dfe8908c01dd572227db3f4f43e6..be5c9bb07880891cbe23550c952f2aed26a93c9a 100644 (file)
@@ -162,6 +162,7 @@ fn get(&self, i: Interned<T>) -> &T {
 pub struct Interner {
     strs: Mutex<TyIntern<String>>,
     paths: Mutex<TyIntern<PathBuf>>,
+    lists: Mutex<TyIntern<Vec<String>>>,
 }
 
 trait Internable: Clone + Eq + Hash + 'static {
@@ -184,6 +185,12 @@ fn intern_cache() -> &'static Mutex<TyIntern<Self>> {
     }
 }
 
+impl Internable for Vec<String> {
+    fn intern_cache() -> &'static Mutex<TyIntern<Self>> {
+        &INTERNER.lists
+    }
+}
+
 impl Interner {
     pub fn intern_str(&self, s: &str) -> Interned<String> {
         self.strs.lock().unwrap().intern_borrow(s)
@@ -195,6 +202,10 @@ pub fn intern_string(&self, s: String) -> Interned<String> {
     pub fn intern_path(&self, s: PathBuf) -> Interned<PathBuf> {
         self.paths.lock().unwrap().intern(s)
     }
+
+    pub fn intern_list(&self, v: Vec<String>) -> Interned<Vec<String>> {
+        self.lists.lock().unwrap().intern(v)
+    }
 }
 
 pub static INTERNER: Lazy<Interner> = Lazy::new(Interner::default);