]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/lib.rs
Switch syntax attribute tracking to BitVector
[rust.git] / src / libsyntax / lib.rs
index 60de94821bba0ba7b87a9a634ab74c36a4d5fa22..16507ec5a5dd53856af13c0aac665948527ec2cb 100644 (file)
@@ -43,6 +43,8 @@
 extern crate serialize as rustc_serialize; // used by deriving
 
 use rustc_data_structures::sync::Lock;
+use rustc_data_structures::bitvec::BitVector;
+use ast::AttrId;
 
 // A variant of 'try!' that panics on an Err. This is used as a crutch on the
 // way towards a non-panic!-prone parser. It should be used for fatal parsing
@@ -75,16 +77,18 @@ macro_rules! unwrap_or {
 }
 
 pub struct Globals {
-    used_attrs: Lock<Vec<u64>>,
-    known_attrs: Lock<Vec<u64>>,
+    used_attrs: Lock<BitVector<AttrId>>,
+    known_attrs: Lock<BitVector<AttrId>>,
     syntax_pos_globals: syntax_pos::Globals,
 }
 
 impl Globals {
     fn new() -> Globals {
         Globals {
-            used_attrs: Lock::new(Vec::new()),
-            known_attrs: Lock::new(Vec::new()),
+            // We have no idea how many attributes their will be, so just
+            // initiate the vectors with 0 bits. We'll grow them as necessary.
+            used_attrs: Lock::new(BitVector::new(0)),
+            known_attrs: Lock::new(BitVector::new(0)),
             syntax_pos_globals: syntax_pos::Globals::new(),
         }
     }