diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2012-11-11 01:59:24 +0200 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2012-11-13 22:48:25 +0200 |
| commit | ce1af8d7023f02e4521cce3bcdbc9fd13d76c5f8 (patch) | |
| tree | b12a8e7d229254c1247870e3bd1e20750396f8d7 /django/db/models/sql | |
| parent | fa18b0ac89723f4ed6e46e744039bf375c8945a5 (diff) | |
Removed use of SortedDict for query.alias_refcount
This will have a smallish impact on performance. Refs #19276.
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/query.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index ce45ec314a..4cfb816958 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -103,7 +103,7 @@ class Query(object): def __init__(self, model, where=WhereNode): self.model = model - self.alias_refcount = SortedDict() + self.alias_refcount = {} # alias_map is the most important data structure regarding joins. # It's used for recording which joins exist in the query and what # type they are. The key is the alias of the joined table (possibly @@ -860,7 +860,7 @@ class Query(object): count. Note that after execution, the reference counts are zeroed, so tables added in compiler will not be seen by this method. """ - return len([1 for count in six.itervalues(self.alias_refcount) if count]) + return len([1 for count in self.alias_refcount.values() if count]) def join(self, connection, reuse=REUSE_ALL, promote=False, outer_if_first=False, nullable=False): @@ -1532,9 +1532,9 @@ class Query(object): # comparison to NULL (e.g. in # Tag.objects.exclude(parent__parent__name='t1'), a tag with no parent # would otherwise be overlooked). - active_positions = [pos for (pos, count) in - enumerate(six.itervalues(query.alias_refcount)) if count] - if active_positions[-1] > 1: + active_positions = len([count for count + in query.alias_refcount.items() if count]) + if active_positions > 1: self.add_filter(('%s__isnull' % prefix, False), negate=True, trim=True, can_reuse=can_reuse) |
