Use union for ClassDef
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 28 Dec 2006 01:06:42 +0000 (20:06 -0500)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 28 Dec 2006 01:06:42 +0000 (20:06 -0500)
src/harfbuzz-ng.cc

index 47d7ebe..ecde88a 100644 (file)
@@ -594,22 +594,24 @@ struct ClassDef {
 
   inline unsigned int get_size (void) const {
     switch (classFormat) {
-    case 1: return ((const ClassDefFormat1&)*this).get_size ();
-    case 2: return ((const ClassDefFormat2&)*this).get_size ();
-    default:return sizeof (ClassDef);
+    case 1: return format1.get_size ();
+    case 2: return format2.get_size ();
+    default:return sizeof (classFormat);
     }
   }
 
   /* Returns 0 if not found. */
   inline int get_class (uint16_t glyph_id) const {
     switch (classFormat) {
-    case 1: return ((const ClassDefFormat1&)*this).get_class(glyph_id);
-    case 2: return ((const ClassDefFormat2&)*this).get_class(glyph_id);
+    case 1: format1.get_class(glyph_id);
+    case 2: format2.get_class(glyph_id);
     default:return 0;
     }
   }
 
   USHORT               classFormat;    /* Format identifier */
+  ClassDefFormat1      format1;
+  ClassDefFormat2      format2;
 };
 
 /*