_getStyle: Avoid calling getAttribute twice for no reason
_getStyle accounted for ~8.9% (~17700) of all calls to getAttribute on devices/hidef/secure-card.svgz file from the Oxygen icon theme. This commit removes this part of the dead weight. Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
5881890e44
commit
c5362743c3
1 changed files with 5 additions and 2 deletions
|
|
@ -1610,9 +1610,12 @@ def removeDuplicateGradients(doc):
|
|||
|
||||
def _getStyle(node):
|
||||
u"""Returns the style attribute of a node as a dictionary."""
|
||||
if node.nodeType == Node.ELEMENT_NODE and len(node.getAttribute('style')) > 0:
|
||||
if node.nodeType != Node.ELEMENT_NODE:
|
||||
return {}
|
||||
style_attribute = node.getAttribute('style')
|
||||
if style_attribute:
|
||||
styleMap = {}
|
||||
rawStyles = node.getAttribute('style').split(';')
|
||||
rawStyles = style_attribute.split(';')
|
||||
for style in rawStyles:
|
||||
propval = style.split(':')
|
||||
if len(propval) == 2:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue