summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@redhat.com>2017-10-11 23:12:38 -0400
committerShaun McCance <shaunm@redhat.com>2017-10-11 23:12:38 -0400
commitd3adf0264ee2b6fd28b7eff7dec33501d6e75a7c (patch)
tree28139fbcd5edac38527b0bc7ceb35a7778ada350
parentf1934cffa7f1809321f68fc156c7039fdb27673b (diff)
downloaditstool-d3adf0264ee2b6fd28b7eff7dec33501d6e75a7c.tar.gz
Fix massive performance issue
Fixed https://github.com/itstool/itstool/issues/15
-rwxr-xr-xitstool.in11
1 files changed, 9 insertions, 2 deletions
diff --git a/itstool.in b/itstool.in
index 60f73dd..c1d0585 100755
--- a/itstool.in
+++ b/itstool.in
@@ -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):