Skip to content

Commit

Permalink
Minor cleanup of hashmap
Browse files Browse the repository at this point in the history
  • Loading branch information
mstewartgallus committed Jul 22, 2013
1 parent fc05819 commit a8870df
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/libstd/hashmap.rs
Expand Up @@ -255,11 +255,8 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
let len_buckets = self.buckets.len();
let bucket = self.buckets[idx].take();

let value = match bucket {
None => None,
Some(Bucket{value, _}) => {
Some(value)
},
let value = do bucket.map_consume |bucket| {
bucket.value
};

/* re-inserting buckets may cause changes in size, so remember
Expand Down Expand Up @@ -505,7 +502,6 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
// `consume_rev_iter` is more efficient than `consume_iter` for vectors
HashMapConsumeIterator {iter: self.buckets.consume_rev_iter()}
}

}

impl<K: Hash + Eq, V: Clone> HashMap<K, V> {
Expand All @@ -524,14 +520,12 @@ impl<K:Hash + Eq,V:Eq> Eq for HashMap<K, V> {
fn eq(&self, other: &HashMap<K, V>) -> bool {
if self.len() != other.len() { return false; }

for self.iter().advance |(key, value)| {
do self.iter().all |(key, value)| {
match other.find(key) {
None => return false,
Some(v) => if value != v { return false },
None => false,
Some(v) => value == v
}
}

true
}

fn ne(&self, other: &HashMap<K, V>) -> bool { !self.eq(other) }
Expand Down

8 comments on commit a8870df

@bors
Copy link
Contributor

@bors bors commented on a8870df Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at mstewartgallus@a8870df

@bors
Copy link
Contributor

@bors bors commented on a8870df Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging sstewartgallus/rust/fubar = a8870df into auto

@bors
Copy link
Contributor

@bors bors commented on a8870df Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sstewartgallus/rust/fubar = a8870df merged ok, testing candidate = 4be29620

@bors
Copy link
Contributor

@bors bors commented on a8870df Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at mstewartgallus@a8870df

@bors
Copy link
Contributor

@bors bors commented on a8870df Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging sstewartgallus/rust/fubar = a8870df into auto

@bors
Copy link
Contributor

@bors bors commented on a8870df Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sstewartgallus/rust/fubar = a8870df merged ok, testing candidate = 0a5d1a1

@bors
Copy link
Contributor

@bors bors commented on a8870df Jul 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 0a5d1a1

Please sign in to comment.