Fixed #28860 -- Removed unnecessary len() calls.

This commit is contained in:
Дилян Палаузов 2017-11-29 11:54:34 -05:00 committed by Tim Graham
parent 3d94ee8500
commit d2afa5eb23
33 changed files with 56 additions and 55 deletions

View file

@ -1433,7 +1433,7 @@ def prefetch_related_objects(model_instances, *related_lookups):
Populate prefetched object caches for a list of model instances based on
the lookups/Prefetch instances given.
"""
if len(model_instances) == 0:
if not model_instances:
return # nothing to do
# We need to be able to dynamically add to the list of prefetch_related
@ -1461,7 +1461,7 @@ def prefetch_related_objects(model_instances, *related_lookups):
through_attrs = lookup.prefetch_through.split(LOOKUP_SEP)
for level, through_attr in enumerate(through_attrs):
# Prepare main instances
if len(obj_list) == 0:
if not obj_list:
break
prefetch_to = lookup.get_current_prefetch_to(level)