diff --git a/Cargo.lock b/Cargo.lock index df394d8aae..9874d44b06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -694,6 +694,11 @@ dependencies = [ "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "linked-hash-map" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "lock_api" version = "0.1.5" @@ -1496,10 +1501,10 @@ version = "0.0.1-dev" dependencies = [ "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "libpng-sys 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "md-5 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2050,6 +2055,7 @@ dependencies = [ "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" "checksum libpng-sys 1.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "939658d8a33e52645ecfdc42500285c8b0fdeb26df10677c32abd13a1fc1d70c" "checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" +"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" diff --git a/dpx/Cargo.toml b/dpx/Cargo.toml index 7b0cd56255..81d918530d 100644 --- a/dpx/Cargo.toml +++ b/dpx/Cargo.toml @@ -15,7 +15,7 @@ md-5 = "0.8.0" sha2 = "0.8.0" rand = "0.7.2" chrono = "0.4.9" -indexmap = "1.3.0" +linked-hash-map = "0.5.2" [features] default = ['libz-sys'] diff --git a/dpx/src/dpx_pdfobj.rs b/dpx/src/dpx_pdfobj.rs index b26f8d4036..95e999de10 100644 --- a/dpx/src/dpx_pdfobj.rs +++ b/dpx/src/dpx_pdfobj.rs @@ -222,12 +222,12 @@ pub struct xref_entry { pub indirect: PdfObjRef, } -use indexmap::IndexMap; +use linked_hash_map::LinkedHashMap; #[derive(Clone)] #[repr(C)] pub struct PdfDict { - inner: IndexMap, + inner: LinkedHashMap, } impl PdfDict { @@ -1186,7 +1186,7 @@ unsafe fn write_dict(dict: &PdfDict, handle: &mut OutputHandleWrapper) { pub fn pdf_new_dict() -> PdfObjRef { safe_new_obj(PdfObjType::DICT, |object| { let boxed = Box::new(PdfDict { - inner: IndexMap::new(), + inner: LinkedHashMap::new(), }); object.data = Box::into_raw(boxed) as *mut libc::c_void; }) @@ -1194,7 +1194,7 @@ pub fn pdf_new_dict() -> PdfObjRef { unsafe fn release_dict(mut data: *mut PdfDict) { let mut boxed = Box::from_raw(data); - for (_k, v) in boxed.inner.drain(..) { + for (_k, &v) in boxed.inner.iter() { unsafe { pdf_release_obj(v); } @@ -1228,12 +1228,12 @@ pub unsafe extern "C" fn pdf_merge_dict(dict1: &mut pdf_obj, dict2: &pdf_obj) { let dict2 = dict2.get_dict(); for (k, &v) in dict2.inner.iter() { let linked = pdf_link_obj(v); - dict1.inner.entry(k.clone()) - .and_modify(|existing| { - let existing = mem::replace(existing, linked); - pdf_release_obj(existing); - }) - .or_insert(linked); + if let Some(existing) = dict1.inner.get_mut(k) { + let existing = mem::replace(existing, linked); + pdf_release_obj(existing); + } else { + dict1.inner.insert(k.clone(), linked); + } } }