Rev 3724: Shave off another 5s by not building 'node_by_key' in http://bzr.arbash-meinel.com/branches/bzr/1.8-dev/lighter_log_file
John Arbash Meinel
john at arbash-meinel.com
Fri Sep 19 02:30:27 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.8-dev/lighter_log_file
------------------------------------------------------------
revno: 3724
revision-id: john at arbash-meinel.com-20080919013023-31adhm4mt3obrjst
parent: john at arbash-meinel.com-20080918204343-0h7rbblut820u6i8
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: lighter_log_file
timestamp: Thu 2008-09-18 20:30:23 -0500
message:
Shave off another 5s by not building 'node_by_key'
-------------- next part --------------
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py 2008-09-03 22:30:56 +0000
+++ b/bzrlib/index.py 2008-09-19 01:30:23 +0000
@@ -366,7 +366,7 @@
self._keys_by_offset = {}
# ready-to-return key:value or key:value, node_ref_lists
self._nodes = {}
- self._nodes_by_key = {}
+ self._nodes_by_key = None
trailers = 0
pos = stream.tell()
lines = stream.read().split('\n')
@@ -381,20 +381,6 @@
else:
node_value = value
self._nodes[key] = node_value
- if self._key_length > 1:
- # TODO: We may want to do this lazily, but if we are calling
- # _buffer_all, we are likely to be doing
- # iter_entries_prefix
- key_dict = self._nodes_by_key
- if self.node_ref_lists:
- key_value = key, node_value[0], node_value[1]
- else:
- key_value = key, node_value
- # For a key of (foo, bar, baz) create
- # _nodes_by_key[foo][bar][baz] = key_value
- for subkey in key[:-1]:
- key_dict = key_dict.setdefault(subkey, {})
- key_dict[key[-1]] = key_value
# cache the keys for quick set intersections
self._keys = set(self._nodes)
if trailers != 1:
@@ -973,7 +959,7 @@
raise errors.BadIndexData(self)
# keys are tuples. Each element is a string that may occur many
# times, so we intern them to save space. AB, RC, 200807
- key = tuple(intern(element) for element in elements[:self._key_length])
+ key = tuple([intern(element) for element in elements[:self._key_length]])
if first_key is None:
first_key = key
absent, references, value = elements[-3:]
More information about the bazaar-commits
mailing list