[rpj-sizeof-array
roland@rolandpj.com**20060424102326
 
 Use inlined array look-up for jhc_sizeof() - should be more compact and faster than fn + switch.
] hunk ./C/FromGrin.hs 377
-    ans = vsep $ [vcat includes,enum_tag_t,header,union_node,text "/* CAFS */", vcat $ map ccaf (grinCafs grin), text "/* Constant Data */", buildConstants finalHcHash,text  "/* Functions */",body]
+    ans = vsep $ [vcat includes,enum_tag_t,header,union_node,text "/* CAFS */", vcat $ map ccaf (grinCafs grin), text "/* Constant Data */", jhc_sizeof_data, buildConstants finalHcHash,text  "/* Functions */",jhc_sizeof,body]
hunk ./C/FromGrin.hs 379
-    (header,body) = generateC (jhc_sizeof:functions) structs
+    (header,body) = generateC (functions) structs
hunk ./C/FromGrin.hs 392
-    jhc_sizeof =  function (name "jhc_sizeof") size_t [(name "tag",tag_t)] [] ( statementRaw $  "switch(tag) {\n" ++ concatMap cs (fsts tags) ++ "}\n_exit(33);")  where
-        cs t = text "  case " <> tshow (nodeTagName t) <> char ':' <+> text "return sizeof(struct " <> tshow (nodeStructName t) <>  text ");\n"
+    jhc_sizeof_data =  text $ "static const uint8_t JHC_SIZEOF[] = {\n" ++ concatMap sizeof (fsts tags) ++ "};"  where
+        sizeof t = text "  sizeof(struct " <> tshow (nodeStructName t) <>  text "),\n"
+    jhc_sizeof = text "static inline size_t jhc_sizeof(tag_t tag) { return (size_t) JHC_SIZEOF[tag]; }"