mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Micro-optimization
This commit is contained in:
parent
707579fa4c
commit
1e1aedbe41
@ -13,12 +13,13 @@ def build_text_map():
|
|||||||
|
|
||||||
def process_node(node):
|
def process_node(node):
|
||||||
nonlocal flat_text
|
nonlocal flat_text
|
||||||
if node.nodeType is Node.TEXT_NODE:
|
nt = node.nodeType
|
||||||
|
if nt is Node.TEXT_NODE:
|
||||||
text = node.nodeValue
|
text = node.nodeValue
|
||||||
if text and text.length:
|
if text and text.length:
|
||||||
node_list.push({'node': node, 'offset': flat_text.length, 'length': text.length})
|
node_list.push(v"{node: node, offset: flat_text.length, length: text.length}")
|
||||||
flat_text += text
|
flat_text += text
|
||||||
elif node.nodeType is Node.ELEMENT_NODE:
|
elif nt is Node.ELEMENT_NODE:
|
||||||
if not node.hasChildNodes():
|
if not node.hasChildNodes():
|
||||||
return
|
return
|
||||||
tag = node.tagName.toLowerCase()
|
tag = node.tagName.toLowerCase()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user