mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Avoid re-parsing identical selectors for class names
This commit is contained in:
parent
0bdabbaeef
commit
304f682808
@ -18,6 +18,7 @@ from calibre.ebooks.oeb.polish.pretty import pretty_script_or_style, pretty_xml_
|
|||||||
from calibre.utils.icu import numeric_sort_key
|
from calibre.utils.icu import numeric_sort_key
|
||||||
from css_selectors import Select, SelectorError
|
from css_selectors import Select, SelectorError
|
||||||
from polyglot.builtins import iteritems, itervalues, unicode_type, filter
|
from polyglot.builtins import iteritems, itervalues, unicode_type, filter
|
||||||
|
from polyglot.functools import lru_cache
|
||||||
|
|
||||||
|
|
||||||
def filter_used_rules(rules, log, select):
|
def filter_used_rules(rules, log, select):
|
||||||
@ -291,6 +292,7 @@ def _classes_in_selector(selector, classes):
|
|||||||
classes.add(cn)
|
classes.add(cn)
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache(maxsize=4096)
|
||||||
def classes_in_selector(text):
|
def classes_in_selector(text):
|
||||||
classes = set()
|
classes = set()
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user