diff options
author | Danilo Šegan <danilo@src.gnome.org> | 2006-12-26 20:22:23 +0000 |
---|---|---|
committer | Danilo Šegan <danilo@src.gnome.org> | 2006-12-26 20:22:23 +0000 |
commit | 75f2f12c78557b663a3c0bdddda253f464300878 (patch) | |
tree | fc6b8f0302604b475786922354f66ea844318a0a /xml2po | |
parent | 3e42bf2151f46d22306902c149e038196c658fc2 (diff) | |
download | gnome-doc-utils-75f2f12c78557b663a3c0bdddda253f464300878.tar.gz |
Smaller performance improvements.
Diffstat (limited to 'xml2po')
-rw-r--r-- | xml2po/ChangeLog | 5 | ||||
-rwxr-xr-x | xml2po/xml2po.py | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/xml2po/ChangeLog b/xml2po/ChangeLog index 5607bd6..e845c1b 100644 --- a/xml2po/ChangeLog +++ b/xml2po/ChangeLog @@ -1,5 +1,10 @@ 2006-12-26 Danilo Šegan <danilo@gnome.org> + * xml2po.py (autoNodeIsFinal): Cache autoNodeIsFinal value. + (worthOutputting): Cache worthOutputting value. + +2006-12-26 Danilo Šegan <danilo@gnome.org> + Fix bug #343749. Support for XHTML mode, partially by Claude Paroz <paroz@email.ch>. diff --git a/xml2po/xml2po.py b/xml2po/xml2po.py index 1834fae..59dcb61 100755 --- a/xml2po/xml2po.py +++ b/xml2po/xml2po.py @@ -410,9 +410,13 @@ def replaceNodeContentsWithText(node,text): def autoNodeIsFinal(node): """Returns 1 if node is text node, contains non-whitespace text nodes or entities.""" + if hasattr(node, '__autofinal__'): + return node.__autofinal__ if node.name in ignored_tags: + node.__autofinal__ = 0 return 0 if node.isText() and node.content.strip()!='': + node.__autofinal__ = 1 return 1 final = 0 child = node.children @@ -422,6 +426,7 @@ def autoNodeIsFinal(node): break child = child.next + node.__autofinal__ = final return final @@ -431,6 +436,10 @@ def worthOutputting(node, noauto = 0): Node is "worth outputting", if none of the parents isFinalNode, and it contains non-blank text and entities. """ + if noauto and hasattr(node, '__worth__'): + return node.__worth__ + elif not noauto and hasattr(node, '__autoworth__'): + return node.__autoworth__ worth = 1 parent = node.parent final = isFinalNode(node) and node.name not in ignored_tags @@ -442,12 +451,15 @@ def worthOutputting(node, noauto = 0): break parent = parent.parent if not worth: + node.__worth__ = 0 return 0 if noauto: + node.__worth__ = worth return worth else: - return autoNodeIsFinal(node) + node.__autoworth__ = autoNodeIsFinal(node) + return node.__autoworth__ def processAttribute(node, attr): if not node or not attr or not worthOutputting(node=node, noauto=1): |