Rev 2263: Cleanup. directly access self._length rather than using len(self) in http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/list_patch

John Arbash Meinel john at arbash-meinel.com
Tue Jan 30 23:01:28 GMT 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/list_patch

------------------------------------------------------------
revno: 2263
revision-id: john at arbash-meinel.com-20070130230124-oqla813fvrfdyvl4
parent: john at arbash-meinel.com-20070130224637-f3c7gx2ya50r1rej
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: list_patch
timestamp: Tue 2007-01-30 17:01:24 -0600
message:
  Cleanup. directly access self._length rather than using len(self)
modified:
  bzrlib/hybrid_linked_list.py   hybrid_linked_list.p-20070130001028-zlexwz74tzo56o2t-1
-------------- next part --------------
=== modified file 'bzrlib/hybrid_linked_list.py'
--- a/bzrlib/hybrid_linked_list.py	2007-01-30 22:46:37 +0000
+++ b/bzrlib/hybrid_linked_list.py	2007-01-30 23:01:24 +0000
@@ -124,7 +124,7 @@
     def __getitem__(self, pos):
         if isinstance(pos, slice):
             # cur, stop, stride are in terms of location in the output list.
-            cur, stop, stride = pos.indices(len(self))
+            cur, stop, stride = pos.indices(self._length)
             result = []
 
             # offset, start, end are in terms of the current content
@@ -162,24 +162,24 @@
 
     def __setitem__(self, pos, value):
         if isinstance(pos, slice):
-            cur, stop, stride = pos.indices(len(self))
+            cur, stop, stride = pos.indices(self._length)
             if stride != 1:
                 raise TypeError('Stride is not supported when setting items.')
             self.replace(cur, stop, value)
         else:
             if pos < 0:
-                pos = len(self) + pos
+                pos = self._length + pos
             self.replace(pos, pos+1, [value])
 
     def __delitem__(self, pos):
         if isinstance(pos, slice):
-            cur, stop, stride = pos.indices(len(self))
+            cur, stop, stride = pos.indices(self._length)
             if stride != 1:
                 raise TypeError('Stride is not supported when deleting items.')
             self.delete(cur, stop)
         else:
             if pos < 0:
-                pos = len(self) + pos
+                pos = self._length + pos
             self.delete(pos, pos+1)
 
     def __str__(self):
@@ -388,8 +388,6 @@
                 # We officially removed enough, so we are done
                 self._length -= remove_length
                 break
-                # we are not removing the start of this node
-                prev_range_id = cur_range_id
 
     def replace(self, start, end, content):
         """Replace a section of existing content, with new content.
@@ -421,7 +419,7 @@
         # Without flattening on the mozilla tree, with 458 deltas, we end up
         # with 4000 links. Which starts being a bottleneck in
         # _find_nodes_for_pos
-        if len(self._links) > self._max_links:
+        if len(self._ranges) > self._max_links:
             self.flatten()
         new_hll = HybridLinkedList()
         new_hll._head = self._head



More information about the bazaar-commits mailing list