Browse Source

fix iter.next ?

dev
BreakWa11 9 years ago
parent
commit
41e92e277e
  1. 6
      shadowsocks/lru_cache.py

6
shadowsocks/lru_cache.py

@ -82,7 +82,8 @@ class LRUCache(collections.MutableMapping):
def first(self): def first(self):
if len(self._keys_to_last_time) > 0: if len(self._keys_to_last_time) > 0:
return iter(self._keys_to_last_time).next() for key in self._keys_to_last_time:
return key
def sweep(self): def sweep(self):
# O(n - m) # O(n - m)
@ -91,7 +92,8 @@ class LRUCache(collections.MutableMapping):
while c < SWEEP_MAX_ITEMS: while c < SWEEP_MAX_ITEMS:
if len(self._keys_to_last_time) == 0: if len(self._keys_to_last_time) == 0:
break break
key = iter(self._keys_to_last_time).next() for key in self._keys_to_last_time:
break
last_t = self._keys_to_last_time[key] last_t = self._keys_to_last_time[key]
if now - last_t <= self.timeout: if now - last_t <= self.timeout:
break break

Loading…
Cancel
Save