[serialize] Only pack main object if there are other objects
authorBehdad Esfahbod <behdad@behdad.org>
Sun, 31 Mar 2019 02:05:51 +0000 (19:05 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Sun, 31 Mar 2019 02:05:51 +0000 (19:05 -0700)
Avoids a memmove for tables that don't use the object packing mechanism.

src/hb-serialize.hh

index 7f32067..6179288 100644 (file)
@@ -122,8 +122,11 @@ struct hb_serialize_context_t
     /* TODO Propagate errors. */
 
     assert (current.length == 1);
-    /* TODO Enable when callers are updated. */
-    //pop_pack ();
+
+    /* Only "pack" if there exist other objects... Otherwise, don't bother.
+     * Saves a copy. */
+    if (packed.length > 1)
+      pop_pack ();
   }
 
   template <typename Type>