From 491b7775b273daf1325a1b050345dbf75b394315 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 11 Jan 2015 01:08:02 +0100 Subject: Reduce size of gperf entity table Don't store length of UTF-8 string. It can be computed by NULL-terminating strings shorter than 4 bytes and using strnlen. Use gperf's string pool option. This allows to use an 'int' index into the string pool instead of a pointer and is helpful on 64-bit systems. Shaves about 75 KB off the 32-bit binaries on Linux and 128 KB off the 64-bit binaries on OS X. --- src/houdini_html_u.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/houdini_html_u.c') diff --git a/src/houdini_html_u.c b/src/houdini_html_u.c index 9a2e262..ecd7faa 100644 --- a/src/houdini_html_u.c +++ b/src/houdini_html_u.c @@ -55,7 +55,8 @@ houdini_unescape_ent(cmark_strbuf *ob, const uint8_t *src, size_t size) const struct html_ent *entity = find_entity((char *)src, i); if (entity != NULL) { - cmark_strbuf_put(ob, entity->utf8, entity->utf8_len); + size_t len = strnlen((const char *)entity->utf8, 4); + cmark_strbuf_put(ob, entity->utf8, len); return i + 1; } -- cgit v1.2.3