diff options
Diffstat (limited to 'src/liburl')
| -rw-r--r-- | src/liburl/lib.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/liburl/lib.rs b/src/liburl/lib.rs index b5ffdef22e9..0b227b68ca8 100644 --- a/src/liburl/lib.rs +++ b/src/liburl/lib.rs @@ -23,6 +23,7 @@ #![feature(default_type_params)] use std::collections::HashMap; +use std::collections::hashmap::{Occupied, Vacant}; use std::fmt; use std::from_str::FromStr; use std::hash; @@ -342,8 +343,10 @@ pub fn decode_form_urlencoded(s: &[u8]) key: String, value: String) { if key.len() > 0 && value.len() > 0 { - let values = map.find_or_insert_with(key, |_| vec!()); - values.push(value); + match map.entry(key) { + Vacant(entry) => { entry.set(vec![value]); }, + Occupied(mut entry) => { entry.get_mut().push(value); }, + } } } |
