Optimized collectstatic when verbosity is 0.

Avoid the dict lookup and length computation when command is not run in
verbose mode.
This commit is contained in:
François Freitag 2020-05-02 19:51:26 +02:00 committed by Mariusz Felisiak
parent 909b5cd1aa
commit e0998a460a
1 changed files with 4 additions and 5 deletions

View File

@ -185,12 +185,12 @@ class Command(BaseCommand):
raise CommandError("Collecting static files cancelled.") raise CommandError("Collecting static files cancelled.")
collected = self.collect() collected = self.collect()
if self.verbosity >= 1:
modified_count = len(collected['modified']) modified_count = len(collected['modified'])
unmodified_count = len(collected['unmodified']) unmodified_count = len(collected['unmodified'])
post_processed_count = len(collected['post_processed']) post_processed_count = len(collected['post_processed'])
return (
if self.verbosity >= 1:
summary = (
"\n%(modified_count)s %(identifier)s %(action)s" "\n%(modified_count)s %(identifier)s %(action)s"
"%(destination)s%(unmodified)s%(post_processed)s." "%(destination)s%(unmodified)s%(post_processed)s."
) % { ) % {
@ -203,7 +203,6 @@ class Command(BaseCommand):
', %s post-processed' ', %s post-processed'
% post_processed_count or ''), % post_processed_count or ''),
} }
return summary
def log(self, msg, level=2): def log(self, msg, level=2):
""" """