[PATCH 1 of 2] util: remove outdated comment about construction overhead
Gregory Szorc
gregory.szorc at gmail.com
Wed Jan 6 05:18:12 UTC 2016
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1452055954 28800
# Tue Jan 05 20:52:34 2016 -0800
# Node ID de3fa1bfeec15608289d07fc45382d0d62800440
# Parent 617f06db4d30f9ce1d6b429fa65de176e4dd7485
util: remove outdated comment about construction overhead
An old implementation of this class (possibly only in my local repo)
allocated nodes in the cache during construction time, making
__init__ slow for large cache capacities. The current implementation
lazily grow the cache size, making this comment wrong.
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -535,20 +535,16 @@ class lrucachedict(object):
The dict consists of an actual backing dict - indexed by original
key - and a doubly linked circular list defining the order of entries in
the cache.
The head node is the newest entry in the cache. If the cache is full,
we recycle head.prev and make it the new head. Cache accesses result in
the node being moved to before the existing head and being marked as the
new head node.
-
- NOTE: construction of this class doesn't scale well if the cache size
- is in the thousands. Avoid creating hundreds or thousands of instances
- with large capacities.
"""
def __init__(self, max):
self._cache = {}
self._head = head = _lrucachenode()
head.prev = head
head.next = head
self._size = 1
More information about the Mercurial-devel
mailing list