about summary refs log tree commit diff
path: root/src/libsyntax/attr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/attr.rs')
-rw-r--r--src/libsyntax/attr.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index ed3ee768708..399a529af15 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -10,9 +10,6 @@
 
 // Functions dealing with attributes and meta items
 
-// BitSet
-#![allow(deprecated)]
-
 pub use self::StabilityLevel::*;
 pub use self::ReprAttr::*;
 pub use self::IntType::*;
@@ -28,20 +25,33 @@ use parse::token;
 use ptr::P;
 
 use std::cell::{RefCell, Cell};
-use std::collections::BitSet;
 use std::collections::HashSet;
 use std::fmt;
 
-thread_local! { static USED_ATTRS: RefCell<BitSet> = RefCell::new(BitSet::new()) }
+thread_local! {
+    static USED_ATTRS: RefCell<Vec<u64>> = RefCell::new(Vec::new())
+}
 
 pub fn mark_used(attr: &Attribute) {
     let AttrId(id) = attr.node.id;
-    USED_ATTRS.with(|slot| slot.borrow_mut().insert(id));
+    USED_ATTRS.with(|slot| {
+        let idx = (id / 64) as usize;
+        let shift = id % 64;
+        if slot.borrow().len() <= idx {
+            slot.borrow_mut().resize(idx + 1, 0);
+        }
+        slot.borrow_mut()[idx] |= 1 << shift;
+    });
 }
 
 pub fn is_used(attr: &Attribute) -> bool {
     let AttrId(id) = attr.node.id;
-    USED_ATTRS.with(|slot| slot.borrow().contains(&id))
+    USED_ATTRS.with(|slot| {
+        let idx = (id / 64) as usize;
+        let shift = id % 64;
+        slot.borrow().get(idx).map(|bits| bits & (1 << shift) != 0)
+            .unwrap_or(false)
+    })
 }
 
 pub trait AttrMetaMethods {