minor, reuse StructAtOffset logic in StructAtOffsetOrNull
authorEbrahim Byagowi <ebrahim@gnu.org>
Fri, 28 Jun 2019 19:14:14 +0000 (23:44 +0430)
committerGitHub <noreply@github.com>
Fri, 28 Jun 2019 19:14:14 +0000 (23:44 +0430)
src/hb-ot-cff-common.hh

index 8b8e592..e89fd1e 100644 (file)
@@ -40,14 +40,14 @@ using namespace OT;
 
 /* utility macro */
 template<typename Type>
-static inline const Type& StructAtOffsetOrNull(const void *P, unsigned int offset)
-{ return offset? (* reinterpret_cast<const Type*> ((const char *) P + offset)): Null(Type); }
+static inline const Type& StructAtOffsetOrNull (const void *P, unsigned int offset)
+{ return offset ? StructAtOffset<Type> (P, offset) : Null (Type); }
 
-inline unsigned int calcOffSize(unsigned int dataSize)
+inline unsigned int calcOffSize (unsigned int dataSize)
 {
   unsigned int size = 1;
   unsigned int offset = dataSize + 1;
-  while ((offset & ~0xFF) != 0)
+  while (offset & ~0xFF)
   {
     size++;
     offset >>= 8;
@@ -58,8 +58,8 @@ inline unsigned int calcOffSize(unsigned int dataSize)
 
 struct code_pair_t
 {
-  hb_codepoint_t  code;
-  hb_codepoint_t  glyph;
+  hb_codepoint_t code;
+  hb_codepoint_t glyph;
 };
 
 typedef hb_vector_t<unsigned char> str_buff_t;