summaryrefslogtreecommitdiff
path: root/django/template
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2021-12-21 07:39:40 +0000
committerGitHub <noreply@github.com>2021-12-21 08:39:40 +0100
commitcc752c1c3a9534dee2377a4ac0d241b8858fe8da (patch)
tree05afa1c6ca27a6902a30873735d2357a440f76f3 /django/template
parent72b23c04d806adc8522fa9d10132e5c1d1011d5e (diff)
Optimized django.template.autoreload.get_template_directories() a bit.
Diffstat (limited to 'django/template')
-rw-r--r--django/template/autoreload.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/template/autoreload.py b/django/template/autoreload.py
index 18570b5633..cf1b20ba95 100644
--- a/django/template/autoreload.py
+++ b/django/template/autoreload.py
@@ -13,18 +13,19 @@ def get_template_directories():
# Iterate through each template backend and find
# any template_loader that has a 'get_dirs' method.
# Collect the directories, filtering out Django templates.
+ cwd = Path.cwd()
items = set()
for backend in engines.all():
if not isinstance(backend, DjangoTemplates):
continue
- items.update(Path.cwd() / to_path(dir) for dir in backend.engine.dirs)
+ items.update(cwd / to_path(dir) for dir in backend.engine.dirs)
for loader in backend.engine.template_loaders:
if not hasattr(loader, 'get_dirs'):
continue
items.update(
- Path.cwd() / to_path(directory)
+ cwd / to_path(directory)
for directory in loader.get_dirs()
if not is_django_path(directory)
)