]> granicus.if.org Git - python/commitdiff
Separate initialization from clearing.
authorRaymond Hettinger <python@rcn.com>
Wed, 25 Mar 2009 22:45:22 +0000 (22:45 +0000)
committerRaymond Hettinger <python@rcn.com>
Wed, 25 Mar 2009 22:45:22 +0000 (22:45 +0000)
Lib/collections.py

index 4f3f72606c6f68b80a70d32a14f168a36cbe96f9..002ce9724de929dc9437f81035a07f456ca7b978 100644 (file)
@@ -41,14 +41,15 @@ class OrderedDict(dict, MutableMapping):
         try:
             self.__root
         except AttributeError:
-            self.__root = _Link()       # sentinel node for the doubly linked list
-            self.clear()
+            self.__root = root = _Link()    # sentinel node for the doubly linked list
+            root.prev = root.next = root
+            self.__map = {}
         self.update(*args, **kwds)
 
     def clear(self):
         root = self.__root
         root.prev = root.next = root
-        self.__map = {}
+        self.__map.clear()
         dict.clear(self)
 
     def __setitem__(self, key, value):