Rev 2369: _get_inventory: 2.09 => 1.93s by tweaking some of the inner _generate_inventory loops in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
John Arbash Meinel
john at arbash-meinel.com
Thu Feb 22 19:54:52 GMT 2007
At http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate
------------------------------------------------------------
revno: 2369
revision-id: john at arbash-meinel.com-20070222195349-10k878qe13qdhoqd
parent: john at arbash-meinel.com-20070222184235-2q0gcimvw3qqudx4
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Thu 2007-02-22 13:53:49 -0600
message:
_get_inventory: 2.09 => 1.93s by tweaking some of the inner _generate_inventory loops
(_get_inventory was originally 2.34s before merging bzr.dev)
modified:
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
-------------- next part --------------
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2007-02-22 18:42:35 +0000
+++ b/bzrlib/workingtree_4.py 2007-02-22 19:53:49 +0000
@@ -40,6 +40,7 @@
import bzrlib
from bzrlib import (
bzrdir,
+ cache_utf8,
conflicts as _mod_conflicts,
dirstate,
errors,
@@ -235,6 +236,10 @@
current_id = root_key[2]
assert current_entry[0][0] == 'd' # directory
inv = Inventory(root_id=current_id)
+ # Turn some things into local variables
+ minikind_to_kind = dirstate.DirState._minikind_to_kind
+ factory = entry_factory
+ utf8_decode = cache_utf8._utf8_decode
# we could do this straight out of the dirstate; it might be fast
# and should be profiled - RBC 20070216
parent_ids = {'' : inv.root.file_id}
@@ -246,15 +251,15 @@
# all the paths in this block are not versioned in this tree
continue
for key, entry in block[1]:
- if entry[0][0] in ('a', 'r'): # absent, relocated
+ minikind, link_or_sha1, size, executable, stat = entry[0]
+ if minikind in ('a', 'r'): # absent, relocated
# a parent tree only entry
continue
name = key[1]
- name_unicode = name.decode('utf8')
+ name_unicode = utf8_decode(name)[0]
file_id = key[2]
- minikind, link_or_sha1, size, executable, stat = entry[0]
- kind = dirstate.DirState._minikind_to_kind[minikind]
- inv_entry = entry_factory[kind](file_id, name_unicode, parent_id)
+ kind = minikind_to_kind[minikind]
+ inv_entry = factory[kind](file_id, name_unicode, parent_id)
if kind == 'file':
# not strictly needed: working tree
#entry.executable = executable
@@ -1016,6 +1021,10 @@
assert current_entry[parent_index][0] == 'd'
inv = Inventory(root_id=current_id, revision_id=self._revision_id)
inv.root.revision = current_entry[parent_index][4]
+ # Turn some things into local variables
+ minikind_to_kind = dirstate.DirState._minikind_to_kind
+ factory = entry_factory
+ utf8_decode = cache_utf8._utf8_decode
# we could do this straight out of the dirstate; it might be fast
# and should be profiled - RBC 20070216
parent_ids = {'' : inv.root.file_id}
@@ -1027,15 +1036,15 @@
# all the paths in this block are not versioned in this tree
continue
for key, entry in block[1]:
- if entry[parent_index][0] in ('a', 'r'): # absent, relocated
+ minikind, link_or_sha1, size, executable, revid = entry[parent_index]
+ if minikind in ('a', 'r'): # absent, relocated
# not this tree
continue
name = key[1]
- name_unicode = name.decode('utf8')
+ name_unicode = utf8_decode(name)[0]
file_id = key[2]
- minikind, link_or_sha1, size, executable, revid = entry[parent_index]
- kind = dirstate.DirState._minikind_to_kind[minikind]
- inv_entry = entry_factory[kind](file_id, name_unicode, parent_id)
+ kind = minikind_to_kind[minikind]
+ inv_entry = factory[kind](file_id, name_unicode, parent_id)
inv_entry.revision = revid
if kind == 'file':
inv_entry.executable = executable
@@ -1046,7 +1055,7 @@
elif kind == 'symlink':
inv_entry.executable = False
inv_entry.text_size = size
- inv_entry.symlink_target = link_or_sha1.decode('utf8')
+ inv_entry.symlink_target = utf8_decode(link_or_sha1)[0]
else:
raise Exception, kind
inv.add(inv_entry)
More information about the bazaar-commits
mailing list