Optimized Query.clone() a bit.
This removes unnecessary "if ... is None" branches, which are already shallow-copied in the __dict__.copy() call.
This commit is contained in:
parent
f1bcaa9be8
commit
2931d847c2
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue