[hb-subset] In batch mode preprocess font once

Speeds up cmap.tests from 3s to under .5s.
diff --git a/util/hb-subset.cc b/util/hb-subset.cc
index c6f8535..1566957 100644
--- a/util/hb-subset.cc
+++ b/util/hb-subset.cc
@@ -50,7 +50,6 @@
   {}
   ~subset_main_t ()
   {
-    hb_font_destroy (font);
     hb_subset_input_destroy (input);
   }
 
@@ -101,8 +100,23 @@
     parse (argc, argv);
 
     hb_face_t* orig_face = face;
+    if (orig_face != cache.face)
+    {
+      hb_face_destroy (cache.face);
+      cache.face = hb_face_reference (orig_face);
+      if (cache.face_preprocessed)
+      {
+        hb_face_destroy (cache.face_preprocessed);
+	cache.face_preprocessed = nullptr;
+      }
+    }
+
     if (preprocess)
-      orig_face = preprocess_face (face);
+    {
+      if (!cache.face_preprocessed)
+        cache.face_preprocessed = preprocess_face (cache.face);
+      orig_face = cache.face_preprocessed;
+    }
 
     hb_face_t *new_face = nullptr;
     for (unsigned i = 0; i < num_iterations; i++)
@@ -122,8 +136,6 @@
       fail (false, "Invalid font file.");
 
     hb_face_destroy (new_face);
-    if (preprocess)
-      hb_face_destroy (orig_face);
 
     return success ? 0 : 1;
   }
@@ -167,9 +179,24 @@
   unsigned num_iterations = 1;
   gboolean preprocess = false;
   hb_subset_input_t *input = nullptr;
-  hb_font_t *font = nullptr;
+
+  static struct cache_t
+  {
+    ~cache_t ()
+    {
+      hb_face_destroy (face);
+      hb_face_destroy (face_preprocessed);
+      hb_font_destroy (font);
+    }
+
+    hb_face_t *face = nullptr;
+    hb_face_t *face_preprocessed = nullptr;
+    hb_font_t *font = nullptr;
+  } cache;
 };
 
+subset_main_t::cache_t subset_main_t::cache {};
+
 static gboolean
 parse_gids (const char *name G_GNUC_UNUSED,
 	    const char *arg,
@@ -276,9 +303,9 @@
   const char *p = arg;
   const char *p_end = arg + strlen (arg);
 
-  if (!subset_main->font)
-    subset_main->font = hb_font_create (subset_main->face);
-  hb_font_t *font = subset_main->font;
+  if (!subset_main->cache.font)
+    subset_main->cache.font = hb_font_create (subset_main->face);
+  hb_font_t *font = subset_main->cache.font;
 
   while (p < p_end)
   {