From 6feb3082aae32d233ab5be93d8de030d6cc57878 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Sun, 3 Apr 2016 19:51:47 +0100 Subject: [PATCH] Better combine_resources --- cpdf.ml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cpdf.ml b/cpdf.ml index 1711756..0af370f 100644 --- a/cpdf.ml +++ b/cpdf.ml @@ -621,15 +621,14 @@ let combine_pdf_resources pdf a b = | Some (Pdf.Dictionary d) -> d | _ -> [] in - key, Pdf.Dictionary (a_entries @ b_entries) + if a_entries = [] && b_entries = [] then + None + else + Some (key, Pdf.Dictionary (a_entries @ b_entries)) in - let unknown_keys_a = - lose (fun (k, _) -> mem k resource_keys) a_entries - in let unknown_keys_b = - lose (fun (k, _) -> mem k resource_keys) b_entries - in let combined_known_entries = - map combine_entries resource_keys - in + let unknown_keys_a = lose (fun (k, _) -> mem k resource_keys) a_entries in + let unknown_keys_b = lose (fun (k, _) -> mem k resource_keys) b_entries in + let combined_known_entries = option_map combine_entries resource_keys in Pdf.Dictionary (unknown_keys_a @ unknown_keys_b @ combined_known_entries) (* \section{Build PDF Presentations} *)