From 53ec8c5b8e192aee5c4dd1e0b367336a4b250cdc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 20 Dec 2019 11:18:05 +0530 Subject: [PATCH] Micro-optimization --- src/calibre/ebooks/docx/block_styles.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/docx/block_styles.py b/src/calibre/ebooks/docx/block_styles.py index 9b90836638..5b1b5b2f61 100644 --- a/src/calibre/ebooks/docx/block_styles.py +++ b/src/calibre/ebooks/docx/block_styles.py @@ -375,7 +375,7 @@ class ParagraphStyle(object): setattr(self, p, binary_property(pPr, p, namespace.XPath, namespace.get)) for x in ('border', 'indent', 'justification', 'spacing', 'shd', 'numbering', 'frame'): - f = globals()['read_%s' % x] + f = read_funcs[x] f(pPr, self, namespace.XPath, namespace.get) for s in namespace.XPath('./w:pStyle[@w:val]')(pPr): @@ -473,3 +473,6 @@ class ParagraphStyle(object): if bw is not inherit and bw and bs is not inherit and bs != 'none': return True return False + + +read_funcs = {k[5:]:v for k, v in iteritems(globals()) if k.startswith('read_')}