make_well_formed: Optimize for the common case of nothing needs to be escaped
Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
9656569a72
commit
397ffc5529
1 changed files with 5 additions and 0 deletions
|
|
@ -3413,6 +3413,11 @@ def remapNamespacePrefix(node, oldprefix, newprefix):
|
|||
def make_well_formed(text, quote_dict=None):
|
||||
if quote_dict is None:
|
||||
quote_dict = XML_ENTS_NO_QUOTES
|
||||
if not any(c in text for c in quote_dict):
|
||||
# The quote-able characters are quite rare in SVG (they mostly only
|
||||
# occur in text elements in practice). Therefore it make sense to
|
||||
# optimize for this common case
|
||||
return text
|
||||
return ''.join(quote_dict[c] if c in quote_dict else c for c in text)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue