Separate initialization from clearing.
This commit is contained in:
parent
2f6f7436aa
commit
2dc90fdfaf
|
@ -41,14 +41,15 @@ class OrderedDict(dict, MutableMapping):
|
||||||
try:
|
try:
|
||||||
self.__root
|
self.__root
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.__root = _Link() # sentinel node for the doubly linked list
|
self.__root = root = _Link() # sentinel node for the doubly linked list
|
||||||
self.clear()
|
root.prev = root.next = root
|
||||||
|
self.__map = {}
|
||||||
self.update(*args, **kwds)
|
self.update(*args, **kwds)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
root = self.__root
|
root = self.__root
|
||||||
root.prev = root.next = root
|
root.prev = root.next = root
|
||||||
self.__map = {}
|
self.__map.clear()
|
||||||
dict.clear(self)
|
dict.clear(self)
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
|
|
Loading…
Reference in New Issue