diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2017-02-02 02:05:56 +0200 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2017-02-10 19:42:41 +0200 |
| commit | aac82d9b13f8ba1baebc5a2a1a673831e6f6fbe7 (patch) | |
| tree | 84cd240a860c08186a117490c5547eae53b89793 /src/librustc_data_structures | |
| parent | 5d70a7fbe489b96272a25b3a75b5f2ef46a846a3 (diff) | |
| download | rust-aac82d9b13f8ba1baebc5a2a1a673831e6f6fbe7.tar.gz rust-aac82d9b13f8ba1baebc5a2a1a673831e6f6fbe7.zip | |
SwitchInt over Switch
This removes another special case of Switch by replacing it with the more general SwitchInt. While this is more clunky currently, there’s no reason we can’t make it nice (and efficient) to use.
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/bitvec.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/librustc_data_structures/bitvec.rs b/src/librustc_data_structures/bitvec.rs index 3700d46c346..ffcd25a4cdd 100644 --- a/src/librustc_data_structures/bitvec.rs +++ b/src/librustc_data_structures/bitvec.rs @@ -30,6 +30,10 @@ impl BitVector { } } + pub fn count(&self) -> usize { + self.data.iter().map(|e| e.count_ones() as usize).sum() + } + #[inline] pub fn contains(&self, bit: usize) -> bool { let (word, mask) = word_mask(bit); |
