Skip to content

Commit

Permalink
apply rustfmt to librustc_data_structures, correcting rust-lang/rustf…
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Mar 5, 2016
1 parent d31d8a9 commit 43dc48c
Show file tree
Hide file tree
Showing 16 changed files with 444 additions and 355 deletions.
36 changes: 21 additions & 15 deletions src/librustc_data_structures/bitvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/// A very simple BitVector type.
pub struct BitVector {
data: Vec<u64>
data: Vec<u64>,
}

impl BitVector {
Expand Down Expand Up @@ -40,7 +40,9 @@ impl BitVector {
for (i, j) in self.data.iter_mut().zip(&all.data) {
let value = *i;
*i = value | *j;
if value != *i { changed = true; }
if value != *i {
changed = true;
}
}
changed
}
Expand All @@ -56,15 +58,15 @@ impl BitVector {
BitVectorIter {
iter: self.data.iter(),
current: 0,
idx: 0
idx: 0,
}
}
}

pub struct BitVectorIter<'a> {
iter: ::std::slice::Iter<'a, u64>,
current: u64,
idx: usize
idx: usize,
}

impl<'a> Iterator for BitVectorIter<'a> {
Expand Down Expand Up @@ -108,7 +110,7 @@ impl BitMatrix {
let u64s_per_elem = u64s(elements);
BitMatrix {
elements: elements,
vector: vec![0; elements * u64s_per_elem]
vector: vec![0; elements * u64s_per_elem],
}
}

Expand All @@ -123,9 +125,9 @@ impl BitMatrix {
let (start, _) = self.range(source);
let (word, mask) = word_mask(target);
let mut vector = &mut self.vector[..];
let v1 = vector[start+word];
let v1 = vector[start + word];
let v2 = v1 | mask;
vector[start+word] = v2;
vector[start + word] = v2;
v1 != v2
}

Expand All @@ -136,7 +138,7 @@ impl BitMatrix {
pub fn contains(&self, source: usize, target: usize) -> bool {
let (start, _) = self.range(source);
let (word, mask) = word_mask(target);
(self.vector[start+word] & mask) != 0
(self.vector[start + word] & mask) != 0
}

/// Returns those indices that are reachable from both `a` and
Expand All @@ -150,8 +152,12 @@ impl BitMatrix {
for (base, (i, j)) in (a_start..a_end).zip(b_start..b_end).enumerate() {
let mut v = self.vector[i] & self.vector[j];
for bit in 0..64 {
if v == 0 { break; }
if v & 0x1 != 0 { result.push(base*64 + bit); }
if v == 0 {
break;
}
if v & 0x1 != 0 {
result.push(base * 64 + bit);
}
v >>= 1;
}
}
Expand All @@ -170,9 +176,7 @@ impl BitMatrix {
let (write_start, write_end) = self.range(write);
let vector = &mut self.vector[..];
let mut changed = false;
for (read_index, write_index) in
(read_start..read_end).zip(write_start..write_end)
{
for (read_index, write_index) in (read_start..read_end).zip(write_start..write_end) {
let v1 = vector[write_index];
let v2 = v1 | vector[read_index];
vector[write_index] = v2;
Expand Down Expand Up @@ -204,7 +208,8 @@ fn bitvec_iter_works() {
bitvec.insert(65);
bitvec.insert(66);
bitvec.insert(99);
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [1, 10, 19, 62, 63, 64, 65, 66, 99]);
assert_eq!(bitvec.iter().collect::<Vec<_>>(),
[1, 10, 19, 62, 63, 64, 65, 66, 99]);
}

#[test]
Expand All @@ -217,7 +222,8 @@ fn bitvec_iter_works_2() {
bitvec.insert(66);
bitvec.insert(99);
bitvec.insert(299);
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [1, 10, 19, 62, 66, 99, 299]);
assert_eq!(bitvec.iter().collect::<Vec<_>>(),
[1, 10, 19, 62, 66, 99, 299]);

}

Expand Down
8 changes: 6 additions & 2 deletions src/librustc_data_structures/fnv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ pub struct FnvHasher(u64);

impl Default for FnvHasher {
#[inline]
fn default() -> FnvHasher { FnvHasher(0xcbf29ce484222325) }
fn default() -> FnvHasher {
FnvHasher(0xcbf29ce484222325)
}
}

impl Hasher for FnvHasher {
Expand All @@ -51,5 +53,7 @@ impl Hasher for FnvHasher {
}

#[inline]
fn finish(&self) -> u64 { self.0 }
fn finish(&self) -> u64 {
self.0
}
}
Loading

0 comments on commit 43dc48c

Please sign in to comment.