[serialize] Movce empty-object handling earlier
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 3 Apr 2019 00:20:04 +0000 (17:20 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 3 Apr 2019 00:20:04 +0000 (17:20 -0700)
src/hb-serialize.hh

index 9b7143e..6a2b6ff 100644 (file)
@@ -172,6 +172,9 @@ struct hb_serialize_context_t
     obj.tail = head;
     unsigned len = obj.tail - obj.head;
 
+    if (!len)
+      return 0;
+
     objidx_t objidx = packed_map.get (&obj);
     if (objidx)
     {
@@ -183,9 +186,6 @@ struct hb_serialize_context_t
     memmove (tail, obj.head, len);
     head = obj.head;
 
-    if (!len)
-      return 0;
-
     obj.head = tail;
     obj.tail = tail + len;