summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2019-01-09 14:55:27 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2019-01-09 14:55:27 +0100
commitf7e4caadfe8f63b5aa14d9266e3c722e9ab4007a (patch)
tree7869b5508bcd6a1ef0a01965839df813a6725aa9
parent5f25b0b6a020c1a368b3d0c9766887c4c95205a9 (diff)
downloadslixmpp-f7e4caadfe8f63b5aa14d9266e3c722e9ab4007a.tar.gz
slixmpp-f7e4caadfe8f63b5aa14d9266e3c722e9ab4007a.tar.bz2
slixmpp-f7e4caadfe8f63b5aa14d9266e3c722e9ab4007a.tar.xz
slixmpp-f7e4caadfe8f63b5aa14d9266e3c722e9ab4007a.zip
Split tag and attrib only once in tostring().
-rw-r--r--slixmpp/xmlstream/tostring.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/slixmpp/xmlstream/tostring.py b/slixmpp/xmlstream/tostring.py
index 6726bf1e..de6fe47d 100644
--- a/slixmpp/xmlstream/tostring.py
+++ b/slixmpp/xmlstream/tostring.py
@@ -45,11 +45,12 @@ def tostring(xml=None, xmlns='', stream=None, outbuffer='',
output = [outbuffer]
# Extract the element's tag name.
- tag_name = xml.tag.split('}', 1)[-1]
+ tag_split = xml.tag.split('}', 1)
+ tag_name = tag_split[-1]
# Extract the element's namespace if it is defined.
if '}' in xml.tag:
- tag_xmlns = xml.tag.split('}', 1)[0][1:]
+ tag_xmlns = tag_split[0][1:]
else:
tag_xmlns = ''
@@ -82,8 +83,9 @@ def tostring(xml=None, xmlns='', stream=None, outbuffer='',
if '}' not in attrib:
output.append(' %s="%s"' % (attrib, value))
else:
- attrib_ns = attrib.split('}')[0][1:]
- attrib = attrib.split('}')[1]
+ attrib_split = attrib.split('}')
+ attrib_ns = attrib_split[0][1:]
+ attrib = attrib_split[1]
if attrib_ns == XML_NS:
output.append(' xml:%s="%s"' % (attrib, value))
elif stream and attrib_ns in stream.namespace_map: