summaryrefslogtreecommitdiff
path: root/django/utils/datastructures.py
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2010-09-11 02:28:16 +0000
committerJustin Bronn <jbronn@gmail.com>2010-09-11 02:28:16 +0000
commit1efa80770382d4995c2d6e67972d8a99021ec81f (patch)
tree5fe1d1450be143d4e76f86d388c2e00757078c20 /django/utils/datastructures.py
parenta56a226241f5808b2eaf1e4b5a155d35047b8a06 (diff)
downloaddjango-1efa80770382d4995c2d6e67972d8a99021ec81f.tar.gz
Fixed #12632 -- Improved performance of `SortedDict`. Thanks, Alex Gaynor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13742 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/datastructures.py')
-rw-r--r--django/utils/datastructures.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index 4656f60f2b..30ce28d38d 100644
--- a/django/utils/datastructures.py
+++ b/django/utils/datastructures.py
@@ -120,9 +120,11 @@ class SortedDict(dict):
self.keyOrder = data.keys()
else:
self.keyOrder = []
+ seen = set()
for key, value in data:
- if key not in self.keyOrder:
+ if key not in seen:
self.keyOrder.append(key)
+ seen.add(key)
def __deepcopy__(self, memo):
return self.__class__([(key, deepcopy(value, memo))