diff options
| author | Adam Johnson <me@adamj.eu> | 2021-09-17 07:08:55 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-09-17 07:12:56 +0200 |
| commit | 2931d847c246b6f499993e370f6d9a53a83120d2 (patch) | |
| tree | 3a65e886ee6fc9c76f8245bf6cddc37bbb1d2092 /django | |
| parent | f1bcaa9be8227dce89a320ce1ca37e1df7c80d03 (diff) | |
Optimized Query.clone() a bit.
This removes unnecessary "if ... is None" branches, which are already
shallow-copied in the __dict__.copy() call.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/sql/query.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 39a735b50e..433824044d 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -303,9 +303,7 @@ class Query(BaseExpression): obj.table_map = self.table_map.copy() obj.where = self.where.clone() obj.annotations = self.annotations.copy() - if self.annotation_select_mask is None: - obj.annotation_select_mask = None - else: + if self.annotation_select_mask is not None: obj.annotation_select_mask = self.annotation_select_mask.copy() obj.combined_queries = tuple(query.clone() for query in self.combined_queries) # _annotation_select_cache cannot be copied, as doing so breaks the @@ -315,13 +313,9 @@ class Query(BaseExpression): # used. obj._annotation_select_cache = None obj.extra = self.extra.copy() - if self.extra_select_mask is None: - obj.extra_select_mask = None - else: + if self.extra_select_mask is not None: obj.extra_select_mask = self.extra_select_mask.copy() - if self._extra_select_cache is None: - obj._extra_select_cache = None - else: + if self._extra_select_cache is not None: obj._extra_select_cache = self._extra_select_cache.copy() if self.select_related is not False: # Use deepcopy because select_related stores fields in nested |
