diff options
| author | Justin Bronn <jbronn@gmail.com> | 2010-09-11 02:30:39 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2010-09-11 02:30:39 +0000 |
| commit | 8829b7d9567a63c5c548272e61447bc2bfdddb12 (patch) | |
| tree | 9972b181415873eae10e63659321895a90561778 | |
| parent | 260eff568423fca4af6456290a8c17a265a04038 (diff) | |
[1.2.X] Fixed #12632 -- Improved performance of `SortedDict`. Thanks, Alex Gaynor.
Backport of r13742 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13743 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/utils/datastructures.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index 3cbbe27b91..d73963fdce 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -99,9 +99,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)) |
