Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
pczarn committed Oct 30, 2016
1 parent 5e9ca83 commit 76c3875
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 77 deletions.
4 changes: 0 additions & 4 deletions src/adaptive_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@

use std::hash::{Hash, BuildHasher};
use std::mem::replace;
use std::ops::{Deref, DerefMut};

use adaptive_hashing::AdaptiveState;
use table::{
RawTable,
SafeHash,
FullBucketMut,
FullBucket,
};
use internal_entry::InternalEntry;
use entry::VacantEntryState;
use HashMap;
use search_hashed;

// Beyond this displacement, we switch to safe hashing or grow the table.
const DISPLACEMENT_THRESHOLD: usize = 128;
Expand Down
25 changes: 0 additions & 25 deletions src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

use std::mem;
use std::ops::Deref;

use table::{EmptyBucket, FullBucket, SafeHash, RawTable};
use internal_entry::InternalEntry;
Expand Down Expand Up @@ -179,30 +178,6 @@ impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V> {
}
}

impl<K, V, M> VacantEntryState<K, V, M> {
pub fn into_table(self) -> M {
match self {
NeqElem(bucket, _) => {
bucket.into_table()
}
NoElem(bucket) => {
bucket.into_table()
}
}
}
}

impl<K, V, M> VacantEntryState<K, V, M> where M: Deref<Target=RawTable<K, V>> {
pub fn displacement(&self, hash: SafeHash) -> usize {
let (index, table_capacity) = match self {
&NeqElem(ref bucket, _) => (bucket.index(), bucket.table().capacity()),
&NoElem(ref bucket) => (bucket.index(), bucket.table().capacity()),
};
// Copied from FullBucket::displacement.
index.wrapping_sub(hash.inspect() as usize) & (table_capacity - 1)
}
}

// These fns are public, but the entire module is not.

#[inline]
Expand Down
24 changes: 1 addition & 23 deletions src/internal_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

use table::{FullBucket, SafeHash, RawTable};
use entry::{self, VacantEntryState, NoElem, NeqElem};
use entry::{self, VacantEntryState};
use Entry;

pub enum InternalEntry<K, V, M> {
Expand Down Expand Up @@ -39,25 +39,3 @@ impl<'a, K, V> InternalEntry<K, V, &'a mut RawTable<K, V>> {
entry::from_internal(self, Some(key))
}
}

impl<K, V, M> InternalEntry<K, V, M> {
#[inline]
pub fn convert_table<M2>(self) -> InternalEntry<K, V, M2> where M: Into<M2> {
// This entire expression should compile down to a simple copy.
match self {
InternalEntry::Occupied { elem } => {
InternalEntry::Occupied { elem: elem.convert_table() }
}
InternalEntry::TableIsEmpty => {
InternalEntry::TableIsEmpty
}
InternalEntry::Vacant { elem, hash } => {
let elem = match elem {
NeqElem(bucket, ib) => NeqElem(bucket.convert_table(), ib),
NoElem(bucket) => NoElem(bucket.convert_table()),
};
InternalEntry::Vacant { elem: elem, hash: hash }
}
}
}
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ impl<K, V, S> HashMap<K, V, S>
/// If the key already exists, the hashtable will be returned untouched
/// and a reference to the existing element will be returned.
fn insert_hashed_nocheck(&mut self, hash: SafeHash, k: K, v: V) -> Option<V> {
let mut entry = search_hashed(&mut self.table, hash, |key| key == &k).into_entry(k);
let entry = search_hashed(&mut self.table, hash, |key| key == &k).into_entry(k);
match entry {
Some(Occupied(mut elem)) => {
Some(elem.insert(v))
Expand Down
24 changes: 0 additions & 24 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,6 @@ impl<K, V, M> FullBucket<K, V, M> {
pub fn into_table(self) -> M {
self.table
}
// Convert the table.
pub fn convert_table<T>(self) -> FullBucket<K, V, T> where M: Into<T> {
FullBucket {
raw: self.raw,
idx: self.idx,
table: self.table.into(),
}
}
/// Get the raw index.
pub fn index(&self) -> usize {
self.idx
Expand All @@ -208,22 +200,6 @@ impl<K, V, M> EmptyBucket<K, V, M> {
pub fn table(&self) -> &M {
&self.table
}
/// Move out the reference to the table.
pub fn into_table(self) -> M {
self.table
}
// Convert the table.
pub fn convert_table<T>(self) -> EmptyBucket<K, V, T> where M: Into<T> {
EmptyBucket {
raw: self.raw,
idx: self.idx,
table: self.table.into(),
}
}
/// Get the raw index.
pub fn index(&self) -> usize {
self.idx
}
}

impl<K, V, M> Bucket<K, V, M> {
Expand Down

0 comments on commit 76c3875

Please sign in to comment.