Skip to content

Commit 35a418e

Browse files
ericktbrson
authored andcommitted
libcore: modernize send_map's whitespacing
1 parent 34bf0b9 commit 35a418e

File tree

1 file changed

+42
-46
lines changed

1 file changed

+42
-46
lines changed

src/libcore/send_map.rs

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ mod linear {
130130
k: &K) -> SearchResult {
131131
let _ = for self.bucket_sequence(hash) |i| {
132132
match buckets[i] {
133-
Some(bkt) => if bkt.hash == hash && *k == bkt.key {
134-
return FoundEntry(i);
135-
},
136-
None => return FoundHole(i)
133+
Some(bkt) => if bkt.hash == hash && *k == bkt.key {
134+
return FoundEntry(i);
135+
},
136+
None => return FoundHole(i)
137137
}
138138
};
139139
return TableFull;
@@ -158,12 +158,12 @@ mod linear {
158158

159159
fn insert_opt_bucket(&mut self, +bucket: Option<Bucket<K,V>>) {
160160
match move bucket {
161-
Some(Bucket {hash: move hash,
162-
key: move key,
163-
value: move value}) => {
164-
self.insert_internal(hash, move key, move value);
165-
}
166-
None => {}
161+
Some(Bucket {hash: move hash,
162+
key: move key,
163+
value: move value}) => {
164+
self.insert_internal(hash, move key, move value);
165+
}
166+
None => {}
167167
}
168168
}
169169

@@ -172,24 +172,24 @@ mod linear {
172172
/// True if there was no previous entry with that key
173173
fn insert_internal(&mut self, hash: uint, +k: K, +v: V) -> bool {
174174
match self.bucket_for_key_with_hash(self.buckets, hash, &k) {
175-
TableFull => {fail ~"Internal logic error";}
176-
FoundHole(idx) => {
177-
debug!("insert fresh (%?->%?) at idx %?, hash %?",
178-
k, v, idx, hash);
179-
self.buckets[idx] = Some(Bucket {hash: hash,
180-
key: k,
181-
value: v});
182-
self.size += 1;
183-
return true;
184-
}
185-
FoundEntry(idx) => {
186-
debug!("insert overwrite (%?->%?) at idx %?, hash %?",
187-
k, v, idx, hash);
188-
self.buckets[idx] = Some(Bucket {hash: hash,
189-
key: k,
190-
value: v});
191-
return false;
192-
}
175+
TableFull => { fail ~"Internal logic error"; }
176+
FoundHole(idx) => {
177+
debug!("insert fresh (%?->%?) at idx %?, hash %?",
178+
k, v, idx, hash);
179+
self.buckets[idx] = Some(Bucket {hash: hash,
180+
key: k,
181+
value: v});
182+
self.size += 1;
183+
true
184+
}
185+
FoundEntry(idx) => {
186+
debug!("insert overwrite (%?->%?) at idx %?, hash %?",
187+
k, v, idx, hash);
188+
self.buckets[idx] = Some(Bucket {hash: hash,
189+
key: k,
190+
value: v});
191+
false
192+
}
193193
}
194194
}
195195

@@ -233,12 +233,8 @@ mod linear {
233233
// http://www.maths.lse.ac.uk/Courses/MA407/del-hash.pdf
234234

235235
let mut idx = match self.bucket_for_key(self.buckets, k) {
236-
TableFull | FoundHole(_) => {
237-
return false;
238-
}
239-
FoundEntry(idx) => {
240-
idx
241-
}
236+
TableFull | FoundHole(_) => return false,
237+
FoundEntry(idx) => idx
242238
};
243239

244240
let len_buckets = self.buckets.len();
@@ -272,8 +268,8 @@ mod linear {
272268
fn contains_key(&const self,
273269
k: &K) -> bool {
274270
match self.bucket_for_key(self.buckets, k) {
275-
FoundEntry(_) => {true}
276-
TableFull | FoundHole(_) => {false}
271+
FoundEntry(_) => {true}
272+
TableFull | FoundHole(_) => {false}
277273
}
278274
}
279275

@@ -318,17 +314,17 @@ mod linear {
318314
impl<K:Hash IterBytes Eq, V: Copy> LinearMap<K,V> {
319315
fn find(&const self, k: &K) -> Option<V> {
320316
match self.bucket_for_key(self.buckets, k) {
321-
FoundEntry(idx) => {
322-
// FIXME (#3148): Once we rewrite found_entry, this
323-
// failure case won't be necessary
324-
match self.buckets[idx] {
325-
Some(bkt) => {Some(copy bkt.value)}
326-
None => fail ~"LinearMap::find: internal logic error"
317+
FoundEntry(idx) => {
318+
// FIXME (#3148): Once we rewrite found_entry, this
319+
// failure case won't be necessary
320+
match self.buckets[idx] {
321+
Some(bkt) => {Some(copy bkt.value)}
322+
None => fail ~"LinearMap::find: internal logic error"
323+
}
324+
}
325+
TableFull | FoundHole(_) => {
326+
None
327327
}
328-
}
329-
TableFull | FoundHole(_) => {
330-
None
331-
}
332328
}
333329
}
334330

0 commit comments

Comments
 (0)