From daaa894960e1b2bce8ee31b7c109be84f598a84e Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Mon, 2 Mar 2020 02:42:06 -0500 Subject: [PATCH] Refs #26064 -- Avoided unnecessary list slicing in migration optimizer. The in_between list is only necessary if an optimization is possible. --- django/db/migrations/optimizer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/db/migrations/optimizer.py b/django/db/migrations/optimizer.py index d1b9d8a0314..f66a318d8a4 100644 --- a/django/db/migrations/optimizer.py +++ b/django/db/migrations/optimizer.py @@ -45,9 +45,9 @@ class MigrationOptimizer: right = True # Should we reduce on the right or on the left. # Compare it to each operation after it for j, other in enumerate(operations[i + 1:]): - in_between = operations[i + 1:i + j + 1] result = operation.reduce(other, app_label) if isinstance(result, list): + in_between = operations[i + 1:i + j + 1] if right: new_operations.extend(in_between) new_operations.extend(result)