From 606dccec6ada96004825ed1972b742078e17ddbb Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 2 May 2018 01:50:19 +0900 Subject: [PATCH] Optimize copy_asset() Instantiate default renderer object only once to reduce the cost. --- sphinx/util/fileutil.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sphinx/util/fileutil.py b/sphinx/util/fileutil.py index 7caf40275..fcbc8abe6 100644 --- a/sphinx/util/fileutil.py +++ b/sphinx/util/fileutil.py @@ -74,6 +74,10 @@ def copy_asset(source, destination, excluded=lambda path: False, context=None, r if not os.path.exists(source): return + if renderer is None: + from sphinx.util.template import SphinxRenderer + renderer = SphinxRenderer() + ensuredir(destination) if os.path.isfile(source): copy_asset_file(source, destination, context, renderer)