diff options
| author | Edward Barnard | 2015-08-29 12:48:57 +0700 | 
|---|---|---|
| committer | Edward Barnard | 2015-08-29 12:48:57 +0700 | 
| commit | 5fbcbdd5f7f3be9d3340e22576b723b44611147b (patch) | |
| tree | 367d858f598c09128b55954eeb8ea203104dd6c0 | |
| parent | c78d39fdf1a0fa9720756ac75e14107f2e72c14a (diff) | |
| download | rust-plist-5fbcbdd5f7f3be9d3340e22576b723b44611147b.tar.bz2 | |
Switch to using BTreeMap for dictionaries
| -rw-r--r-- | src/builder.rs | 13 | ||||
| -rw-r--r-- | src/lib.rs | 4 | 
2 files changed, 7 insertions, 10 deletions
diff --git a/src/builder.rs b/src/builder.rs index 50afad7..d1eec78 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::BTreeMap;  use std::io::{Read, Seek};  use {ParserError, ParserResult, Plist, PlistEvent, StreamingParser}; @@ -102,11 +102,8 @@ impl<T:Iterator<Item=ParserResult<PlistEvent>>> Builder<T> {  		}  	} -	fn build_dict(&mut self, len: Option<u64>) -> Result<HashMap<String, Plist>, BuilderError> { -		let mut values = match len { -			Some(len) => HashMap::with_capacity(len as usize), -			None => HashMap::new() -		}; +	fn build_dict(&mut self, len: Option<u64>) -> Result<BTreeMap<String, Plist>, BuilderError> { +		let mut values = BTreeMap::new();  		loop {  			try!(self.bump()); @@ -127,7 +124,7 @@ impl<T:Iterator<Item=ParserResult<PlistEvent>>> Builder<T> {  #[cfg(test)]  mod tests { -	use std::collections::HashMap; +	use std::collections::BTreeMap;  	use super::*;  	use Plist; @@ -165,7 +162,7 @@ mod tests {  		lines.push(Plist::String("It is a tale told by an idiot,".to_owned()));  		lines.push(Plist::String("Full of sound and fury, signifying nothing.".to_owned())); -		let mut dict = HashMap::new(); +		let mut dict = BTreeMap::new();  		dict.insert("Author".to_owned(), Plist::String("William Shakespeare".to_owned()));  		dict.insert("Lines".to_owned(), Plist::Array(lines));  		dict.insert("Birthdate".to_owned(), Plist::Integer(1564)); @@ -12,14 +12,14 @@ pub use builder::{Builder, BuilderError, BuilderResult};  use chrono::{DateTime, UTC};  use chrono::format::ParseError as ChronoParseError; -use std::collections::HashMap; +use std::collections::BTreeMap;  use std::io::{Read, Seek, SeekFrom};  use std::io::Error as IoError;  #[derive(Clone, Debug, PartialEq)]  pub enum Plist {  	Array(Vec<Plist>), -	Dictionary(HashMap<String, Plist>), +	Dictionary(BTreeMap<String, Plist>),  	Boolean(bool),  	Data(Vec<u8>),  	Date(DateTime<UTC>),  | 
