diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2021-05-15 19:41:55 +0100 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2021-05-15 19:59:24 +0100 |
commit | 4de031adb16019295d67fe02e515f9982b32a74b (patch) | |
tree | 862c501a041c5e2cd4a987226175b40c6774a6ac /src/treebuilder/element-type.h | |
parent | 6c69e82879901a3a8f5eb19914e7ffc4224d0eca (diff) | |
download | libhubbub-4de031adb16019295d67fe02e515f9982b32a74b.tar.gz libhubbub-4de031adb16019295d67fe02e515f9982b32a74b.tar.bz2 |
Treebuilder: Massively optimise element type from name with gperf.
Loading the html5 single page spec:
* We were spending 10.81% of total runtime in
element_type_from_name. Now it takes 0.66%
of total runtime.
* Total instruction fetch cost is reduced from
5,660,475,511 to 4,523,112,517.
Diffstat (limited to 'src/treebuilder/element-type.h')
-rw-r--r-- | src/treebuilder/element-type.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/treebuilder/element-type.h b/src/treebuilder/element-type.h new file mode 100644 index 0000000..08f58de --- /dev/null +++ b/src/treebuilder/element-type.h @@ -0,0 +1,49 @@ +/* + * This file is part of Hubbub. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2008 John-Mark Bell <jmb@netsurf-browser.org> + */ + +#ifndef hubbub_treebuilder_element_type_h_ +#define hubbub_treebuilder_element_type_h_ + +#include "treebuilder/treebuilder.h" + +typedef enum +{ +/* Special */ + ADDRESS, AREA, ARTICLE, ASIDE, BASE, BASEFONT, BGSOUND, BLOCKQUOTE, + BODY, BR, CENTER, COL, COLGROUP, COMMAND, DATAGRID, DD, DETAILS, + DIALOG, DIR, DIV, DL, DT, EMBED, FIELDSET, FIGCAPTION, FIGURE, FOOTER, + FORM, FRAME, FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HEADER, HR, IFRAME, + IMAGE, IMG, INPUT, ISINDEX, LI, LINK, LISTING, MAIN, MENU, META, NAV, + NOEMBED, NOFRAMES, NOSCRIPT, OL, OPTGROUP, OPTION, P, PARAM, PLAINTEXT, + PRE, SCRIPT, SECTION, SELECT, SPACER, STYLE, SUMMARY, TBODY, TEXTAREA, + TFOOT, THEAD, TITLE, TR, UL, WBR, +/* Scoping */ + APPLET, BUTTON, CAPTION, HTML, MARQUEE, OBJECT, TABLE, TD, TH, +/* Formatting */ + A, B, BIG, CODE, EM, FONT, I, NOBR, S, SMALL, STRIKE, STRONG, TT, U, +/* Phrasing */ + /**< \todo Enumerate phrasing elements */ + LABEL, OUTPUT, RP, RT, RUBY, SPAN, SUB, SUP, VAR, XMP, +/* MathML */ + MATH, MGLYPH, MALIGNMARK, MI, MO, MN, MS, MTEXT, ANNOTATION_XML, +/* SVG */ + SVG, FOREIGNOBJECT, /* foreignobject is scoping, but only in SVG ns */ + DESC, + UNKNOWN +} element_type; + +struct element_type_map { + const char *name; + element_type type; +}; + +const struct element_type_map *hubbub_element_type_lookup( + register const char *str, + register size_t len); + +#endif + |