diff options
author | Shaun McCance <shaunm@redhat.com> | 2017-10-11 23:12:38 -0400 |
---|---|---|
committer | Shaun McCance <shaunm@redhat.com> | 2017-10-11 23:12:38 -0400 |
commit | d3adf0264ee2b6fd28b7eff7dec33501d6e75a7c (patch) | |
tree | 28139fbcd5edac38527b0bc7ceb35a7778ada350 | |
parent | f1934cffa7f1809321f68fc156c7039fdb27673b (diff) | |
download | itstool-d3adf0264ee2b6fd28b7eff7dec33501d6e75a7c.tar.gz |
Fix massive performance issue
Fixed https://github.com/itstool/itstool/issues/15
-rwxr-xr-x | itstool.in | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -553,6 +553,9 @@ class Document (object): self._itst_credits = None self._its_externals = {} + def __del__ (self): + self._doc.freeDoc() + def _check_errors(self): if self._xml_err: raise libxml2.parserError(self._xml_err) @@ -1039,8 +1042,11 @@ class Document (object): ctxt = libxml2.createDocParserCtxt(blurb) if self._load_dtd: ctxt.loadSubset(1) - ctxt.ctxtUseOptions(libxml2.XML_PARSE_DTDLOAD) - ctxt.replaceEntities(0) + if self._keep_entities: + ctxt.ctxtUseOptions(libxml2.XML_PARSE_DTDLOAD) + ctxt.replaceEntities(0) + else: + ctxt.replaceEntities(1) ctxt.parseDocument() trnode = ctxt.doc().getRootElement() try: @@ -1082,6 +1088,7 @@ class Document (object): retnode = node.copyNode(2) for child in xml_child_iter(trnode): retnode.addChild(child.copyNode(1)) + ctxt.doc().freeDoc() return retnode def generate_messages(self, comments=True): |