diff options
author | Dmitry Polienko <dmitry@eldis.ru> | 2016-12-01 09:14:14 +0700 |
---|---|---|
committer | Dmitry Polienko <dmitry@eldis.ru> | 2016-12-01 09:14:14 +0700 |
commit | ff69656f80a6494eecad3bd41e9c1d8e68e7f5b7 (patch) | |
tree | 52c019c997e728d9a6c8785ca1011cfb7fc9c24d /lib/pure/xmltree.nim | |
parent | 6bd86f7543ba0ab7d40764a206fdd5183ce8eb88 (diff) | |
download | Nim-ff69656f80a6494eecad3bd41e9c1d8e68e7f5b7.tar.gz |
Clean up (as suggested by @Araq)
Diffstat (limited to 'lib/pure/xmltree.nim')
-rw-r--r-- | lib/pure/xmltree.nim | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/pure/xmltree.nim b/lib/pure/xmltree.nim index 5385705cd..7cfb62157 100644 --- a/lib/pure/xmltree.nim +++ b/lib/pure/xmltree.nim @@ -97,19 +97,18 @@ proc innerText*(n: XmlNode): string = ## - If `n` is `xnElement`, runs recursively on each child node and ## concatenates the results. ## - Otherwise returns an empty string. - var res = "" - proc worker(n: XmlNode) = + proc worker(res: var string, n: XmlNode) = case n.k - of { xnText, xnEntity }: + of xnText, xnEntity: res.add(n.fText) of xnElement: for sub in n.s: - worker(sub) + worker(res, sub) else: discard - worker(n) - res + result = "" + worker(result, n) proc tag*(n: XmlNode): string {.inline.} = ## gets the tag name of `n`. `n` has to be an ``xnElement`` node. |