Skip to content

Commit b5be7d8

Browse files
committed
Avoid range checks in HashMap::each()
1 parent f323b0c commit b5be7d8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libcore/hashmap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> {
303303

304304
/// Visit all key-value pairs
305305
fn each<'a>(&'a self, blk: &fn(&K, &'a V) -> bool) -> bool {
306-
for uint::range(0, self.buckets.len()) |i| {
307-
for self.buckets[i].each |bucket| {
308-
if !blk(&bucket.key, &bucket.value) {
306+
for self.buckets.each |bucket| {
307+
for bucket.each |pair| {
308+
if !blk(&pair.key, &pair.value) {
309309
return false;
310310
}
311311
}

0 commit comments

Comments
 (0)