about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-03-06 19:31:37 -0800
committerbors <bors@rust-lang.org>2014-03-06 19:31:37 -0800
commit28e7631d8beadd8762adefde2346266732e1866d (patch)
tree45bf9567494031bb19ab614ccfbe3bd2d6925076
parent5862c0c28b7d25f1a1f8fd9165eff1f6f3d191d8 (diff)
parent42389b7069a21679d6b92229d825b860121125d9 (diff)
auto merge of #12746 : alexcrichton/rust/issue-12743, r=brson
The arguments were accidentally swapped in the wrong order.

Closes #12743
-rw-r--r--src/libcollections/hashmap.rs21
-rw-r--r--src/libserialize/collection_impls.rs4
2 files changed, 13 insertions, 12 deletions
diff --git a/src/libcollections/hashmap.rs b/src/libcollections/hashmap.rs
index b4b843289f8..1d73fae11b0 100644
--- a/src/libcollections/hashmap.rs
+++ b/src/libcollections/hashmap.rs
@@ -358,13 +358,13 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
     pub fn with_capacity(capacity: uint) -> HashMap<K, V> {
         let mut r = rand::task_rng();
         let hasher = SipHasher::new_with_keys(r.gen(), r.gen());
-        HashMap::with_capacity_and_hasher(hasher, capacity)
+        HashMap::with_capacity_and_hasher(capacity, hasher)
     }
 }
 
 impl<K: Hash<S> + Eq, V, S, H: Hasher<S>> HashMap<K, V, H> {
     pub fn with_hasher(hasher: H) -> HashMap<K, V, H> {
-        HashMap::with_capacity_and_hasher(hasher, INITIAL_CAPACITY)
+        HashMap::with_capacity_and_hasher(INITIAL_CAPACITY, hasher)
     }
 
     /// Create an empty HashMap with space for at least `capacity`
@@ -374,7 +374,7 @@ impl<K: Hash<S> + Eq, V, S, H: Hasher<S>> HashMap<K, V, H> {
     /// is designed to allow HashMaps to be resistant to attacks that
     /// cause many collisions and very poor performance. Setting it
     /// manually using this function can expose a DoS attack vector.
-    pub fn with_capacity_and_hasher(hasher: H, capacity: uint) -> HashMap<K, V, H> {
+    pub fn with_capacity_and_hasher(capacity: uint, hasher: H) -> HashMap<K, V, H> {
         let cap = max(INITIAL_CAPACITY, capacity);
         HashMap {
             hasher: hasher,
@@ -587,7 +587,8 @@ impl<K: Hash<S> + Eq, V: Eq, S, H: Hasher<S>> Eq for HashMap<K, V, H> {
 
 impl<K: Hash<S> + Eq + Clone, V:Clone, S, H: Hasher<S> + Clone> Clone for HashMap<K, V, H> {
     fn clone(&self) -> HashMap<K, V, H> {
-        let mut new_map = HashMap::with_capacity_and_hasher(self.hasher.clone(), self.len());
+        let mut new_map = HashMap::with_capacity_and_hasher(self.len(),
+                                                            self.hasher.clone());
         for (key, value) in self.iter() {
             new_map.insert((*key).clone(), (*value).clone());
         }
@@ -714,7 +715,7 @@ impl<K> Iterator<K> for SetMoveItems<K> {
 impl<K: Hash<S> + Eq, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> for HashMap<K, V, H> {
     fn from_iterator<T: Iterator<(K, V)>>(iter: &mut T) -> HashMap<K, V, H> {
         let (lower, _) = iter.size_hint();
-        let mut map = HashMap::with_capacity_and_hasher(Default::default(), lower);
+        let mut map = HashMap::with_capacity_and_hasher(lower, Default::default());
         map.extend(iter);
         map
     }
@@ -730,7 +731,7 @@ impl<K: Hash<S> + Eq, V, S, H: Hasher<S> + Default> Extendable<(K, V)> for HashM
 
 impl<K: Hash<S> + Eq, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H> {
     fn default() -> HashMap<K, V, H> {
-        HashMap::with_capacity_and_hasher(Default::default(), INITIAL_CAPACITY)
+        HashMap::with_capacity_and_hasher(INITIAL_CAPACITY, Default::default())
     }
 }
 
@@ -802,7 +803,7 @@ impl<T: Hash<SipState> + Eq> HashSet<T, SipHasher> {
 
 impl<T: Hash<S> + Eq, S, H: Hasher<S>> HashSet<T, H> {
     pub fn with_hasher(hasher: H) -> HashSet<T, H> {
-        HashSet::with_capacity_and_hasher(hasher, INITIAL_CAPACITY)
+        HashSet::with_capacity_and_hasher(INITIAL_CAPACITY, hasher)
     }
 
     /// Create an empty HashSet with space for at least `capacity`
@@ -812,9 +813,9 @@ impl<T: Hash<S> + Eq, S, H: Hasher<S>> HashSet<T, H> {
     /// are designed to allow HashSets to be resistant to attacks that
     /// cause many collisions and very poor performance. Setting them
     /// manually using this function can expose a DoS attack vector.
-    pub fn with_capacity_and_hasher(hasher: H, capacity: uint) -> HashSet<T, H> {
+    pub fn with_capacity_and_hasher(capacity: uint, hasher: H) -> HashSet<T, H> {
         HashSet {
-            map: HashMap::with_capacity_and_hasher(hasher, capacity)
+            map: HashMap::with_capacity_and_hasher(capacity, hasher)
         }
     }
 
@@ -902,7 +903,7 @@ impl<T: fmt::Show + Hash<S> + Eq, S, H: Hasher<S>> fmt::Show for HashSet<T, H> {
 impl<T: Hash<S> + Eq, S, H: Hasher<S> + Default> FromIterator<T> for HashSet<T, H> {
     fn from_iterator<Iter: Iterator<T>>(iter: &mut Iter) -> HashSet<T, H> {
         let (lower, _) = iter.size_hint();
-        let mut set = HashSet::with_capacity_and_hasher(Default::default(), lower);
+        let mut set = HashSet::with_capacity_and_hasher(lower, Default::default());
         set.extend(iter);
         set
     }
diff --git a/src/libserialize/collection_impls.rs b/src/libserialize/collection_impls.rs
index 4db91346402..2d86734e569 100644
--- a/src/libserialize/collection_impls.rs
+++ b/src/libserialize/collection_impls.rs
@@ -192,7 +192,7 @@ impl<
     fn decode(d: &mut D) -> HashMap<K, V, H> {
         d.read_map(|d, len| {
             let hasher = Default::default();
-            let mut map = HashMap::with_capacity_and_hasher(hasher, len);
+            let mut map = HashMap::with_capacity_and_hasher(len, hasher);
             for i in range(0u, len) {
                 let key = d.read_map_elt_key(i, |d| Decodable::decode(d));
                 let val = d.read_map_elt_val(i, |d| Decodable::decode(d));
@@ -228,7 +228,7 @@ impl<
 > Decodable<D> for HashSet<T, H> {
     fn decode(d: &mut D) -> HashSet<T, H> {
         d.read_seq(|d, len| {
-            let mut set = HashSet::with_capacity_and_hasher(Default::default(), len);
+            let mut set = HashSet::with_capacity_and_hasher(len, Default::default());
             for i in range(0u, len) {
                 set.insert(d.read_seq_elt(i, |d| Decodable::decode(d)));
             }