diff options
| author | Michael Woerister <michaelwoerister@posteo.net> | 2016-04-22 14:07:23 -0400 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo.net> | 2016-04-28 16:53:00 -0400 |
| commit | 0fc9f9a20080753426772eac77d4d135ccd01ab7 (patch) | |
| tree | 8a8608422fde56ab13be64ed3e7adf9a8abff549 /src/librustc_data_structures | |
| parent | 7f04d35cc6ca34e94a0635bde76a401f7f4a65da (diff) | |
| download | rust-0fc9f9a20080753426772eac77d4d135ccd01ab7.tar.gz rust-0fc9f9a20080753426772eac77d4d135ccd01ab7.zip | |
Make the codegen unit partitioner also emit item declarations.
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/bitvec.rs | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/librustc_data_structures/bitvec.rs b/src/librustc_data_structures/bitvec.rs index 092b406ae9e..cb648038c34 100644 --- a/src/librustc_data_structures/bitvec.rs +++ b/src/librustc_data_structures/bitvec.rs @@ -52,9 +52,8 @@ impl BitVector { pub fn grow(&mut self, num_bits: usize) { let num_words = u64s(num_bits); - let extra_words = self.data.len() - num_words; - if extra_words > 0 { - self.data.extend((0..extra_words).map(|_| 0)); + if self.data.len() < num_words { + self.data.resize(num_words, 0) } } @@ -284,15 +283,27 @@ fn union_two_vecs() { #[test] fn grow() { let mut vec1 = BitVector::new(65); - assert!(vec1.insert(3)); - assert!(!vec1.insert(3)); - assert!(vec1.insert(5)); - assert!(vec1.insert(64)); + for index in 0 .. 65 { + assert!(vec1.insert(index)); + assert!(!vec1.insert(index)); + } vec1.grow(128); - assert!(vec1.contains(3)); - assert!(vec1.contains(5)); - assert!(vec1.contains(64)); - assert!(!vec1.contains(126)); + + // Check if the bits set before growing are still set + for index in 0 .. 65 { + assert!(vec1.contains(index)); + } + + // Check if the new bits are all un-set + for index in 65 .. 128 { + assert!(!vec1.contains(index)); + } + + // Check that we can set all new bits without running out of bounds + for index in 65 .. 128 { + assert!(vec1.insert(index)); + assert!(!vec1.insert(index)); + } } #[test] |
