@@ -108,19 +108,17 @@ pub mod linear {
108
108
}
109
109
110
110
#[ inline( always) ]
111
- pure fn bucket_for_key ( & self , buckets : & [ Option < Bucket < K , V > > ] ,
112
- k : & K ) -> SearchResult {
111
+ pure fn bucket_for_key ( & self , k : & K ) -> SearchResult {
113
112
let hash = k. hash_keyed ( self . k0 , self . k1 ) as uint ;
114
- self . bucket_for_key_with_hash ( buckets , hash, k)
113
+ self . bucket_for_key_with_hash ( hash, k)
115
114
}
116
115
117
116
#[ inline( always) ]
118
117
pure fn bucket_for_key_with_hash ( & self ,
119
- buckets : & [ Option < Bucket < K , V > > ] ,
120
118
hash : uint ,
121
119
k : & K ) -> SearchResult {
122
120
let _ = for self . bucket_sequence( hash) |i| {
123
- match buckets[ i] {
121
+ match self . buckets [ i] {
124
122
Some ( ref bkt) => if bkt. hash == hash && * k == bkt. key {
125
123
return FoundEntry ( i) ;
126
124
} ,
@@ -161,7 +159,7 @@ pub mod linear {
161
159
/// Assumes that there will be a bucket.
162
160
/// True if there was no previous entry with that key
163
161
fn insert_internal ( & mut self , hash : uint , k : K , v : V ) -> bool {
164
- match self . bucket_for_key_with_hash ( self . buckets , hash, & k) {
162
+ match self . bucket_for_key_with_hash ( hash, & k) {
165
163
TableFull => { die ! ( ~"Internal logic error"); }
166
164
FoundHole(idx) => {
167
165
debug!(" insert fresh ( %?->%?) at idx %?, hash %?",
@@ -196,8 +194,7 @@ pub mod linear {
196
194
//
197
195
// I found this explanation elucidating:
198
196
// http://www.maths.lse.ac.uk/Courses/MA407/del-hash.pdf
199
- let mut idx = match self.bucket_for_key_with_hash(self.buckets,
200
- hash, k) {
197
+ let mut idx = match self.bucket_for_key_with_hash(hash, k) {
201
198
TableFull | FoundHole(_) => return None,
202
199
FoundEntry(idx) => idx
203
200
};
@@ -273,7 +270,7 @@ pub mod linear {
273
270
impl <K: Hash IterBytes Eq, V> LinearMap<K, V>: Map<K, V> {
274
271
/// Return true if the map contains a value for the specified key
275
272
pure fn contains_key(&self, k: &K) -> bool {
276
- match self.bucket_for_key(self.buckets, k) {
273
+ match self.bucket_for_key(k) {
277
274
FoundEntry(_) => {true}
278
275
TableFull | FoundHole(_) => {false}
279
276
}
@@ -291,7 +288,7 @@ pub mod linear {
291
288
292
289
/// Return the value corresponding to the key in the map
293
290
pure fn find(&self, k: &K) -> Option<&self/V> {
294
- match self.bucket_for_key(self.buckets, k) {
291
+ match self.bucket_for_key(k) {
295
292
FoundEntry(idx) => {
296
293
match self.buckets[idx] {
297
294
Some(ref bkt) => {
0 commit comments