Created
September 5, 2019 19:44
-
-
Save ensonic/7cdf81d9b682132b06573fbc0a6896ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd $HOME/projects/gnome/glib/build/docs/reference/glib | |
xtime python3 /home/ensonic/projects/gnome/gtk-doc/gtkdoc-mkhtml2 --path=../../../../docs/reference/glib/ --output-dir=html glib glib-docs.xml | |
2.07u 0.15s 2.25r 140428kB | |
git diff gtkdoc/mkhtml2.py | |
diff --git a/gtkdoc/mkhtml2.py b/gtkdoc/mkhtml2.py | |
index f54a80d..3bb5b12 100644 | |
--- a/gtkdoc/mkhtml2.py | |
+++ b/gtkdoc/mkhtml2.py | |
@@ -1751,6 +1751,22 @@ def create_devhelp2(out_dir, module, xml, files): | |
idx.write(line) | |
+class FakeDTDResolver(etree.Resolver): | |
+ """Don't load the docbookx.dtd since we disable the validation anyway. | |
+ | |
+ libxsml2 does not cache DTDs. If we produce a docbook file with 100 chunks | |
+ loading such a doc with xincluding will load and parse the docbook DTD 100 | |
+ times. This cases tons of memory allocations and is slow. | |
+ """ | |
+ | |
+ def resolve(self, url, id, context): | |
+ if url.endswith('.xml'): | |
+ return None | |
+ # http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd | |
+ return self.resolve_string( | |
+ '<!ENTITY myentity "[resolved text: %s]">' % url, context) | |
+ | |
+ | |
def main(module, index_file, out_dir, uninstalled, src_lang, paths): | |
# == Loading phase == | |
@@ -1758,10 +1774,10 @@ def main(module, index_file, out_dir, uninstalled, src_lang, paths): | |
# 1) load the docuemnt | |
_t = timer() | |
- # does not seem to be faster | |
- # parser = etree.XMLParser(dtd_validation=False, collect_ids=False) | |
- # tree = etree.parse(index_file, parser) | |
- tree = etree.parse(index_file) | |
+ parser = etree.XMLParser(dtd_validation=False, collect_ids=False, | |
+ load_dtd=True) | |
+ parser.resolvers.add(FakeDTDResolver()) | |
+ tree = etree.parse(index_file, parser) | |
logging.warning("1a: %7.3lf: load doc", timer() - _t) | |
_t = timer() | |
tree.xinclude() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment