@@ -130,10 +130,10 @@ mod linear {
130
130
k : & K ) -> SearchResult {
131
131
let _ = for self . bucket_sequence( hash) |i| {
132
132
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)
137
137
}
138
138
} ;
139
139
return TableFull ;
@@ -158,12 +158,12 @@ mod linear {
158
158
159
159
fn insert_opt_bucket ( & mut self , +bucket : Option < Bucket < K , V > > ) {
160
160
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 => { }
167
167
}
168
168
}
169
169
@@ -172,24 +172,24 @@ mod linear {
172
172
/// True if there was no previous entry with that key
173
173
fn insert_internal ( & mut self , hash : uint , +k : K , +v : V ) -> bool {
174
174
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
+ }
193
193
}
194
194
}
195
195
@@ -233,12 +233,8 @@ mod linear {
233
233
// http://www.maths.lse.ac.uk/Courses/MA407/del-hash.pdf
234
234
235
235
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
242
238
} ;
243
239
244
240
let len_buckets = self . buckets . len ( ) ;
@@ -272,8 +268,8 @@ mod linear {
272
268
fn contains_key ( & const self ,
273
269
k : & K ) -> bool {
274
270
match self . bucket_for_key ( self . buckets , k) {
275
- FoundEntry ( _) => { true }
276
- TableFull | FoundHole ( _) => { false }
271
+ FoundEntry ( _) => { true }
272
+ TableFull | FoundHole ( _) => { false }
277
273
}
278
274
}
279
275
@@ -318,17 +314,17 @@ mod linear {
318
314
impl < K : Hash IterBytes Eq , V : Copy > LinearMap < K , V > {
319
315
fn find ( & const self , k : & K ) -> Option < V > {
320
316
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
327
327
}
328
- }
329
- TableFull | FoundHole ( _) => {
330
- None
331
- }
332
328
}
333
329
}
334
330
0 commit comments