diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2018-07-30 08:39:03 -0600 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2018-08-01 06:48:42 -0600 |
| commit | 1d64b241cdca1477cc4c87b3751326212ebf78f6 (patch) | |
| tree | 2a77cf6735bd3bac9ae6b21ff6c5ff2d0366ff17 /src/libsyntax/attr | |
| parent | 8c069ceba81a0fffc1ce95aaf7e8339e11bf2796 (diff) | |
| download | rust-1d64b241cdca1477cc4c87b3751326212ebf78f6.tar.gz rust-1d64b241cdca1477cc4c87b3751326212ebf78f6.zip | |
Switch syntax attribute tracking to BitVector
Diffstat (limited to 'src/libsyntax/attr')
| -rw-r--r-- | src/libsyntax/attr/mod.rs | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 137b94230a3..7fbc5d4c41a 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -41,51 +41,27 @@ use std::iter; pub fn mark_used(attr: &Attribute) { debug!("Marking {:?} as used.", attr); - let AttrId(id) = attr.id; GLOBALS.with(|globals| { - let mut slot = globals.used_attrs.lock(); - let idx = (id / 64) as usize; - let shift = id % 64; - if slot.len() <= idx { - slot.resize(idx + 1, 0); - } - slot[idx] |= 1 << shift; + globals.used_attrs.lock().insert(attr.id); }); } pub fn is_used(attr: &Attribute) -> bool { - let AttrId(id) = attr.id; GLOBALS.with(|globals| { - let slot = globals.used_attrs.lock(); - let idx = (id / 64) as usize; - let shift = id % 64; - slot.get(idx).map(|bits| bits & (1 << shift) != 0) - .unwrap_or(false) + globals.used_attrs.lock().contains(attr.id) }) } pub fn mark_known(attr: &Attribute) { debug!("Marking {:?} as known.", attr); - let AttrId(id) = attr.id; GLOBALS.with(|globals| { - let mut slot = globals.known_attrs.lock(); - let idx = (id / 64) as usize; - let shift = id % 64; - if slot.len() <= idx { - slot.resize(idx + 1, 0); - } - slot[idx] |= 1 << shift; + globals.known_attrs.lock().insert(attr.id); }); } pub fn is_known(attr: &Attribute) -> bool { - let AttrId(id) = attr.id; GLOBALS.with(|globals| { - let slot = globals.known_attrs.lock(); - let idx = (id / 64) as usize; - let shift = id % 64; - slot.get(idx).map(|bits| bits & (1 << shift) != 0) - .unwrap_or(false) + globals.known_attrs.lock().contains(attr.id) }) } |
